标签:bsp int c++ open pen display scanf name event
https://codeforc.es/problemset/problem/1216/B
这题还是贪心,直接排序即可 。
1 #include<bits/stdc++.h> 2 using namespace std; 3 int const N=1000+10; 4 int a[N],n,b[N]; 5 int cmp(int x,int y){ 6 return a[x]>a[y]; 7 } 8 int main(){ 9 scanf("%d",&n); 10 for(int i=1;i<=n;i++) 11 scanf("%d",&a[i]); 12 for(int i=1;i<=n;i++) 13 b[i]=i; 14 sort(b+1,b+n+1,cmp); 15 int ans=n; 16 for(int i=1;i<=n;i++) 17 ans+=a[b[i]]*(i-1); 18 printf("%d\n",ans); 19 for(int i=1;i<=n;i++) 20 printf("%d ",b[i]); 21 return 0; 22 }
标签:bsp int c++ open pen display scanf name event
原文地址:https://www.cnblogs.com/ZJXXCN/p/11594880.html