1 solutions

  • 0
    @ 2024-11-27 22:28:31
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e7+9;
    
    struct stu
    {
    	int id;
    	int val;
    }st[N];
    
    bool cmp(stu a,stu b)
    {
    	if(a.val>b.val)return true;
    	else return false;
    }
    
    int main()
    {
    	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    	
    	int n;cin>>n;
    	for(int i=1;i<=n;++i)
    	{
    		cin>>st[i].val;
    		st[i].id=i;
    	}
    	sort(st+1,st+1+n,cmp);
    	cout<<st[1].val<<' '<<st[1].id<<'\n'<<st[n].val<<' '<<st[n].id;
    	
    	
    	return 0;
    }
    
    

    Information

    ID
    4611
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By