Submission #773203

#TimeUsernameProblemLanguageResultExecution timeMemory
773203NK_Teams (CEOI11_tea)C++17
40 / 100
589 ms78684 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' 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<pair<int, int>> B; for(int i = 0; i < N; i++) B.push_back(make_pair(A[i], i)); sort(rbegin(B), rend(B)); V<V<int>> C; V<int> ex; for(int i = 0; i < N; i++) { int left = N - i; if (left < B[i].first) { ex.push_back(B[i].second); } else { int r = i + B[i].first; C.push_back({}); for(int x = i; x < r; x++) C.back().push_back(B[x].second); i = r - 1; } } int lo = 0, hi = N; while(lo < hi) { int mid = (lo + hi) / 2; int have = 0, need = size(ex); for(auto v : C) have += mid - size(v); if (have >= need) hi = mid; else lo = mid + 1; } int mx = lo; cout << size(C) << nl; for(auto v : C) { while(size(ex) && int(size(v)) < mx) v.push_back(ex.back()), ex.pop_back(); cout << size(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...