# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
773312 |
2023-07-04T21:02:51 Z |
NK_ |
Teams (CEOI11_tea) |
C++17 |
|
452 ms |
123712 KB |
// 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;
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);
int idx = -(*begin(siz)).s;
// cout << idx << " " << sz(C) - 1 << endl;
// assert(idx == (sz(C) - 1));
// 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;
}
}
for(int i = 0; i < sz(ex); i++) {
int left = sz(ex) - i;
assert(left < A[ex[i]]);
}
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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2180 KB |
Output is correct |
2 |
Correct |
15 ms |
2308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
2384 KB |
Output is correct |
2 |
Correct |
16 ms |
2512 KB |
Output is correct |
3 |
Correct |
18 ms |
2288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
17708 KB |
Output is correct |
2 |
Correct |
152 ms |
20268 KB |
Output is correct |
3 |
Correct |
160 ms |
18704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
23724 KB |
Output is correct |
2 |
Correct |
452 ms |
123712 KB |
Output is correct |
3 |
Correct |
197 ms |
26404 KB |
Output is correct |
4 |
Correct |
198 ms |
20784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
221 ms |
25964 KB |
Output is correct |
2 |
Correct |
145 ms |
26980 KB |
Output is correct |
3 |
Correct |
206 ms |
23660 KB |
Output is correct |
4 |
Correct |
223 ms |
23716 KB |
Output is correct |