Submission #773309

# Submission time Handle Problem Language Result Execution time Memory
773309 2023-07-04T20:54:29 Z NK_ Teams (CEOI11_tea) C++17
80 / 100
520 ms 125620 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;
	for(int i = 0; i < N; i++) {
		int left = N - i;
		if (left < B[i].first) {
			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; 
		}
	}
 
	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 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 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 2 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 2164 KB Output is correct
2 Correct 16 ms 2540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2460 KB Output is correct
2 Correct 20 ms 2632 KB Output is correct
3 Correct 19 ms 2780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 17708 KB Output is correct
2 Correct 163 ms 22488 KB Output is correct
3 Correct 161 ms 23176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 227 ms 23664 KB Output is correct
2 Correct 520 ms 125620 KB Output is correct
3 Correct 201 ms 29288 KB Output is correct
4 Correct 216 ms 25680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 224 ms 26000 KB Output is correct
2 Correct 147 ms 27668 KB Output is correct
3 Correct 203 ms 24356 KB Output is correct
4 Correct 227 ms 29488 KB Output is correct