Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <queue>
- #include <algorithm>
- using namespace std;
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- int proverka=n-1;
- vector<pair<int, int>>v;
- for(int i=0; i<n; i++){
- int a;
- cin>>a;
- v.push_back(make_pair(a,i));
- }
- sort(v.begin(), v.end());
- vector<pair<int, int>>v_;
- int counter=0;
- for(int x = 0; x <v.size(); x++ ){
- bool ok = false;
- for(int i=v.size()-1; i>=0; i--){
- if(v[i].first<=0){
- continue;
- }
- for(int j=0; j<n; j++){
- if(i != j){
- if(v[i].first<=0){
- continue;
- }
- if(v[j].first<=0){
- continue;
- }
- v[i].first--;
- v[j].first--;
- counter++;
- v_.push_back(make_pair(v[i].second+1, v[j].second+1));
- ok = true;
- break;
- }
- }
- if(ok) {
- break;
- }
- }
- sort(v.begin(), v.end());
- }
- if(counter<n){
- for(int i=0; i<v_.size(); i++){
- cout<<v_[i].first<<" "<<v_[i].second<<endl;
- }
- }
- else{
- cout<<"PROBLEM";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement