Submission #1107880

#TimeUsernameProblemLanguageResultExecution timeMemory
1107880MuhammetGift (IZhO18_nicegift)C++17
18 / 100
20 ms4308 KiB
#include <bits/stdc++.h> using namespace std; #define sz(s) (int)s.size() #define ff first #define ss second int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector <int> a(n); multiset <pair<int,int>> s; for(int i = 0; i < n; i++){ cin >> a[i]; if(a[i] == 0) continue; s.insert({a[i],i+1}); } vector <pair<int,int>> v; while(sz(s) > 1){ pair <int,int> x = *(--s.end()); s.erase(--s.end()); pair <int,int> y = *(--s.end()); s.erase(--s.end()); x.ff--; y.ff--; if(x.ff != 0) s.insert(x); if(y.ff != 0) s.insert(y); v.push_back({x.ss,y.ss}); } if(sz(s) == 1){ cout << -1; return 0; } cout << sz(v) << "\n"; for(auto i : v){ cout << 1 << ' ' << i.ff << ' ' << i.ss << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...