Submission #329109

# Submission time Handle Problem Language Result Execution time Memory
329109 2020-11-19T06:11:16 Z thecodingwizard Teams (CEOI11_tea) C++11
50 / 100
2500 ms 16300 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define ii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define inf 1000000010

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int n; cin >> n;
    vector<ii> A;
    F0R(i, n) {
        int x; cin >> x; A.pb(mp(x,i+1));
    }
    sort(all(A));

    int teams = 1;
    vector<int> breakpoints;
    for (int i = 0; i < n-A.back().f; i++) {
        int curSz = 1;
        while (curSz < A[i].f && i+1 < n-A.back().f) {
            curSz++;
            i++;
        }
        if (curSz >= A[i].f) {
            teams++;
            breakpoints.pb(i);
        }
    }

    breakpoints.pb(n-1);

    for (int i = breakpoints.size()-2; ~i; i--) {
        int j;
        for (j = breakpoints[i+1]-A[breakpoints[i+1]].f; ; j--) {
            if (j-(i==0?-1:breakpoints[i-1]) >= A[j].f) break;
        }
        breakpoints[i] = j;
    }

    for (int x = 0; x < n; x++) {
    for (int i = 0; i < (int)breakpoints.size()-1; i++) {
        while (breakpoints[i]-(i==0?-1:breakpoints[i-1]) > breakpoints[i+1]-breakpoints[i]+1) {
            breakpoints[i]--;
        }
    }
    }

    cout << teams << endl;
    int curIdx = 0;
    for (int x : breakpoints) {
        cout << x - curIdx + 1;
        assert(x-curIdx+1>=A[x].f);
        for (; curIdx <= x; curIdx++) cout << " " << A[curIdx].s;
        cout << endl;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 6 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
2 Incorrect 2 ms 500 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 370 ms 11856 KB Output is correct
2 Execution timed out 2541 ms 10464 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 319 ms 15568 KB Output is correct
2 Execution timed out 2578 ms 16300 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 317 ms 15696 KB Output is correct
2 Correct 236 ms 15568 KB Output is correct
3 Correct 2083 ms 15696 KB Output is correct
4 Correct 568 ms 15696 KB Output is correct