Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using db = double;
- using ll = long long;
- using ld = long double;
- #define ss s.size()
- #define ss_s sort(s.begin(), s.end())
- using namespace std;
- void FastIO()
- {
- ios::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- freopen("error.txt", "w", stderr);
- #endif
- }
- bool comp(pair<int, int> a, pair<int, int> b)
- {
- if (a.first == b.first)
- return a.second < b.second;
- return a.first > b.first;
- }
- int main()
- {
- FastIO();
- int num, sum = 0;
- cin >> num;
- pair<int, int> arr[num];
- for (ll i = 0; i < num; i++)
- {
- cin >> arr[i].first;
- arr[i].second = i + 1;
- }
- sort(arr, arr + num, comp);
- for (ll i = 0; i < num; i++)
- {
- sum += ((arr[i].first * i) + 1);
- }
- cout << sum << endl;
- for (ll i = 0; i < num; i++)
- {
- cout << arr[i].second << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement