Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- using namespace std;
- const int dim = 1003;
- struct cutie
- {
- int val, poz;
- };
- cutie v[dim];
- bool comparator(cutie A, cutie B)
- {
- if(A.val>=B.val)
- return true;
- else
- return false;
- }
- int main()
- {
- int n, i;
- long long s = 0;
- ios::sync_with_stdio(false);
- cin.tie(0);
- cin>>n;
- for( i = 0; i < n; ++i)
- {
- cin >> v[i].val;
- v[ i ].poz = i;
- }
- sort(v, v+n, comparator);
- for( i = 0; i < n; ++i )
- s += v[i].val*i + 1;
- cout<<s<<endl;
- for(i=0;i<n;i++)
- cout<<v[i].poz+1<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement