SHARE
TWEET

asdfg

a guest Oct 23rd, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4. const int dim = 1003;
  5.  
  6. struct cutie
  7. {
  8.     int val, poz;
  9. };
  10. cutie v[dim];
  11. bool comparator(cutie A, cutie B)
  12. {
  13.     if(A.val>=B.val)
  14.         return true;
  15.     else
  16.         return false;
  17. }
  18.  
  19. int main()
  20. {
  21.     int  n, i;
  22.     long long s = 0;
  23.     ios::sync_with_stdio(false);
  24.     cin.tie(0);
  25.  
  26.     cin>>n;
  27.     for( i = 0; i < n; ++i)
  28.     {
  29.         cin >> v[i].val;
  30.         v[ i ].poz = i;
  31.     }
  32.     sort(v, v+n, comparator);
  33.     for( i = 0; i < n; ++i )
  34.         s += v[i].val*i + 1;
  35.  
  36.     cout<<s<<endl;
  37.  
  38.     for(i=0;i<n;i++)
  39.         cout<<v[i].poz+1<<" ";
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top