#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef long double LD; typedef pair < int, int > PII; typedef pair < LL, LL > PLL; typedef pair < LD, LD > PDD; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define st first #define nd second #define pb push_back #define REP(i,a,b) for(int i = (a); i <= (b); i++) #define FOR(i, n) REP(i, 0, int(n) - 1) #define pii pair < int, int > #define ll long long #define fi first #define se second #define mp make_pair #define vi vector <int> vector<int> v; //set<pii> S; int main() { ios_base::sync_with_stdio(0); int n, sum = 0; cin>>n; FOR(i,n) { int a; cin>>a; v.pb(a); //S.insert(mp(a,i+1)); sum += a; } sort(v.begin(), v.end()); /*if( sum == 2*(n-1)){ cout<<"0\nn\n"; FOR(i,n-1) { pii small = *S.begin(), big = *S.rbegin(); S.erase(small); S.erase(big); cout<<small.se<<" "<<big.se<<"\n"; big.fi--; S.insert(big); } }*/ if(v[0] == 1 && v[1] == 1) cout<<"0\n2\n1 2\n"; else if(v[0] == 1) cout<<"1\n2\n1 2\n"; else cout<<"2\n2\n1 2\n"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef long double LD; typedef pair < int, int > PII; typedef pair < LL, LL > PLL; typedef pair < LD, LD > PDD; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define st first #define nd second #define pb push_back #define REP(i,a,b) for(int i = (a); i <= (b); i++) #define FOR(i, n) REP(i, 0, int(n) - 1) #define pii pair < int, int > #define ll long long #define fi first #define se second #define mp make_pair #define vi vector <int> vector<int> v; //set<pii> S; int main() { ios_base::sync_with_stdio(0); int n, sum = 0; cin>>n; FOR(i,n) { int a; cin>>a; v.pb(a); //S.insert(mp(a,i+1)); sum += a; } sort(v.begin(), v.end()); /*if( sum == 2*(n-1)){ cout<<"0\nn\n"; FOR(i,n-1) { pii small = *S.begin(), big = *S.rbegin(); S.erase(small); S.erase(big); cout<<small.se<<" "<<big.se<<"\n"; big.fi--; S.insert(big); } }*/ if(v[0] == 1 && v[1] == 1) cout<<"0\n2\n1 2\n"; else if(v[0] == 1) cout<<"1\n2\n1 2\n"; else cout<<"2\n2\n1 2\n"; return 0; } |