Submission #773228

#TimeUsernameProblemLanguageResultExecution timeMemory
773228NK_Teams (CEOI11_tea)C++17
80 / 100
479 ms125640 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' #define f first #define s second #define mp make_pair #define sz(x) int(x.size()) using pi = pair<int, int>; template<class T> using V = vector<T>; int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; V<int> A(N); for(auto& x : A) cin >> x; V<pi> B; for(int i = 0; i < N; i++) B.push_back(mp(A[i], i)); sort(rbegin(B), rend(B)); V<V<int>> C; multiset<pi> siz; for(int i = 0; i < N; i++) { int left = N - i; if (left < B[i].first) { int idx = (*begin(siz)).s; assert(sz(C[idx])+1 >= B[i].first); siz.erase(begin(siz)); C[idx].push_back(B[i].second); siz.insert(mp(sz(C[idx]), idx)); } else { int r = i + B[i].first; C.push_back({}); for(int x = i; x < r; x++) C.back().push_back(B[x].second); siz.insert(mp(sz(C.back()), sz(C) - 1)); i = r - 1; } } int mx = 0; for(auto v : C) mx = max(mx, sz(v)); // cout << mx << nl; cout << sz(C) << nl; for(auto v : C) { cout << sz(v) << " "; for(auto x : v) cout << x + 1 << " "; cout << nl; } return 0; }
#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...