zoukankan      html  css  js  c++  java
  • codeforces 101341M

     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
  • 相关阅读:
    freemaker获取字符串长度
    freemarker截取字符串subString
    [转]freemarker中的list
    python常用模块——os模块
    python正则表达式
    需要区分对比的函数以及函数小结
    信道极限容量
    信道和调制
    python中颜色设置
    python中的exec()、eval()以及complie()
  • 原文地址:https://www.cnblogs.com/NWUACM/p/6842382.html
Copyright © 2011-2022 走看看