Submission #57491

# Submission time Handle Problem Language Result Execution time Memory
57491 2018-07-15T07:33:08 Z 윤교준(#1672) Teams (CEOI11_tea) C++11
80 / 100
566 ms 110932 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

const int MAXN = 1000005;

priority_queue<pii, vector<pii>, greater<pii>> PQ;
vector<int> AnsV[MAXN];

vector<int> BV[MAXN];
int A[MAXN], B[MAXN];

int N, AnsC;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	for(int i = 1; i <= N; i++) BV[B[i]].eb(i);
	sort(A+1, A+N+1); reverse(A+1, A+N+1);

	for(int i = 1; i <= N;) {
		if(i+A[i]-1 <= N) {
			AnsC++;
			for(int j = i; j < i+A[i]; j++)
				AnsV[AnsC].eb(A[j]);
			PQ.push(pii(A[i], AnsC));
			i += A[i];
			continue;
		}

		for(int idx, cnt;;) {
			tie(cnt, idx) = PQ.top(); PQ.pop();
			if(sz(AnsV[idx]) != cnt) continue;

			AnsV[idx].eb(A[i]);
			PQ.push(pii(cnt+1, idx));
			break;
		}

		i++;
	}

	printf("%d\n", AnsC);
	for(int i = 1; i <= AnsC; i++) {
		printf("%d ", sz(AnsV[i]));
		for(int v : AnsV[i]) {
			printf("%d ", BV[v].back());
			BV[v].pop_back();
		}
		puts("");
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 40 ms 47228 KB Output is correct
2 Correct 47 ms 47460 KB Output is correct
3 Correct 41 ms 47460 KB Output is correct
4 Correct 49 ms 47460 KB Output is correct
5 Correct 52 ms 47460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 47460 KB Output is correct
2 Correct 50 ms 47460 KB Output is correct
3 Correct 50 ms 47472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 47472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 47628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 47628 KB Output is correct
2 Correct 46 ms 47736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 49588 KB Output is correct
2 Correct 85 ms 49928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 50032 KB Output is correct
2 Correct 73 ms 50064 KB Output is correct
3 Correct 87 ms 50836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 383 ms 67624 KB Output is correct
2 Correct 250 ms 69376 KB Output is correct
3 Correct 251 ms 69376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 350 ms 74616 KB Output is correct
2 Correct 473 ms 110932 KB Output is correct
3 Correct 303 ms 110932 KB Output is correct
4 Correct 386 ms 110932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 392 ms 110932 KB Output is correct
2 Correct 412 ms 110932 KB Output is correct
3 Correct 392 ms 110932 KB Output is correct
4 Correct 566 ms 110932 KB Output is correct