NWU_ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 #define rep(i,a,b) for(LL i = a;i <= b;++ i)
 4 #define per(i,a,b) for(LL i = a;i >= b;-- i)
 5 #define mem(a,b) memset((a),(b),sizeof((a)))
 6 #define FIN freopen("in.txt","r",stdin)
 7 #define IO ios_base::sync_with_stdio(0),cin.tie(0)
 8 #define pb push_back
 9 #define INF 0x3f3f3f3f
10 #define mod 1000000007
11 typedef long long LL;
12 typedef pair<int, int> PIR;
13 const int N = 2e5+5;
14 
15 int n, x;
16 struct Node{
17     int id, c;
18     Node (int _id, int _c)  { id = _id; c = _c; }
19     bool operator < (const Node &r) const { return c < r.c; }
20 };
21 vector <Node> v1, v2;
22 vector <PIR> ans;
23 
24 int main()
25 {IO;
26     //FIN;
27     cin >> n;
28     rep(i, 1, n){
29         cin >> x;
30         if(x == 0)  v2.pb(Node(i, x));
31         else v1.pb(Node(i, x));
32     }
33     sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end());
34     int ok = 1;
35     rep(i, 0, (int)v1.size()-1){
36         if(v2.size() < v1[i].c){
37             ok = 0;
38             break;
39         }
40         int cnt = v1[i].c;
41         while(cnt){
42             ans.pb(PIR(v1[i].id, v2[v2.size()-1].id));
43             cnt--;
44             v2.pop_back();
45         }
46         v2.pb(Node(v1[i].id, 0));
47     }
48     if(!ok) cout << "NO" << endl;
49     else{
50         cout << "YES" << endl;
51         rep(i, 0, (int)ans.size()-1)    cout << ans[i].first << " " << ans[i].second << endl;
52     }
53     return 0;
54 }
View Code

 

posted on 2017-05-11 19:31  NWU_ACM  阅读(118)  评论(0编辑  收藏  举报