Saleh127

codeforces 1216B.cpp

May 31st, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define pi acos(-1)
  6. int main()
  7. {
  8. int c,d=0,e,f,i,j,k,l;
  9. cin>>c;
  10. pair<int,int>a[c];
  11. for(i=0;i<c;i++)
  12. {
  13. cin>>a[i].first;
  14. a[i].second=i+1;
  15. }
  16. sort(a,a+c);
  17. reverse(a,a+c);
  18. for(i=0;i<c;i++)
  19. {
  20. d+=(a[i].first*i+1);
  21. }
  22. cout<<d<<endl;
  23. for(i=0;i<c;i++)
  24. {
  25. printf("%d ",a[i].second);
  26. }
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment