Submission #1111397

#TimeUsernameProblemLanguageResultExecution timeMemory
1111397freefire123Teams (CEOI11_tea)C++14
30 / 100
265 ms97184 KiB
#include <bits/stdc++.h> #define ii pair < int , int > #define fi first #define se second #define int long long #define FOR(i, a, b) for(int i = (a); i <= (b); i++) using namespace std; void maximize(int &A, int B) { if(A < B) A = B; return; } void minimize(int &A, int B) { if(A > B) A = B; return; } const int N = 1e6 + 5; const int mod = 1e9 + 7; int n; ii a[N]; vector < int > team[N]; priority_queue < ii , vector < ii > , greater < ii > > q; bool cmp(ii a, ii b) { return a.fi > b.fi; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; FOR(i, 1, n){ cin >> a[i].fi; a[i].se = i; } sort(a + 1, a + n + 1, cmp); int cnt = 0, save = n + 1; FOR(i, 1, n){ if(i + a[i].fi - 1 > n){ save = i; break; } cnt++; for(int j = i; j <= i + a[i].fi - 1; j++){ team[cnt].push_back(a[j].se); } i = i + a[i].fi - 1; } FOR(i, 1, cnt){ q.push(ii((int)team[i].size(), i)); } FOR(i, save, n){ int I = q.top().se; q.pop(); team[I].push_back(a[i].se); q.push(ii((int)team[I].size(), I)); } cout << cnt << '\n'; FOR(i, 1, cnt){ cout << (int)team[i].size() << " "; for(int &v : team[i]){ cout << v << " "; } cout << '\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...
#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...