2 solutions
-
1
季总写法:
#include<bits/stdc++.h> using namespace std; const int N=1010; struct Node { int id; int t; }p[N]; bool cmp(Node a,Node b) { if(a.t<b.t) return 1; if(a.t==b.t&&a.id<b.id) return 1; return 0; } int main() { int n; cin>>n; for(int i=0;i<n;i++) { cin>>p[i].t; p[i].id=i+1; } sort(p,p+n,cmp); long long s=0; for(int i=0;i<n;i++) { cout<<p[i].id<<" "; s=s+(n-1-(i+1)+1)*p[i].t; } cout<<endl; printf("%.2lf",s*1.0/n); }
Information
- ID
- 1018
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- (None)
- # Submissions
- 46
- Accepted
- 15
- Uploaded By