1 solutions

  • 0
    @ 2025-11-5 16:14:43

    C++ :

    #include <cstdlib>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    struct person{
    	int id;
    	int time;
    }a[102];
    int comp(const person a,const person b)
    {
    	return a.time<b.time;
    }
    int main()
    {
    	int n;
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++)
    	{
    		a[i].id=i;
    		scanf("%d",&a[i].time);
    	}
    	sort(a+1,a+n+1,comp);
    	int sum=0;bool first=0;
    	for(int i=1;i<=n;i++)
    	{
    		if(first==0)
    		{
    			printf("%d",a[i].id);
    			first=1;
    		}
    		else
    			printf(" %d",a[i].id);
    		sum+=(n-i+1)*a[i].time;
    		
    	}
    	printf("\n%.2lf",(double)(sum/n));
    	return 0;
    }
    
    
    • 1

    Information

    ID
    17605
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By