Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main(){
- ios::sync_with_stdio(false);
- cin.tie(0);
- int n;
- cin >> n;
- vector<pair<int, int>> a(n);
- for(int i = 0; i < n; i++)
- {
- cin >> a[i].first;
- a[i].second = i + 1;
- }
- sort(a.begin(), a.end(), greater<pair<int, int>>());
- int l = 1;
- for(int i = 0; i < n; i++)
- {
- for(; a[i].first > 0 && l < n; l++)
- {
- cout << a[i].second << " " << a[l].second << "\n";
- a[l].first--;
- a[i].first--;
- }
- }
- /*7
- 3 2 1 2 1 2 1*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement