Submission #685410

# Submission time Handle Problem Language Result Execution time Memory
685410 2023-01-24T10:16:21 Z Johann Teams (CEOI11_tea) C++14
30 / 100
299 ms 89844 KB
#include "bits/stdc++.h"
using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vpii A(n);
    for (int i = 0; i < n; ++i)
        cin >> A[i].first, A[i].second = i;

    sort(all(A), greater<pii>());
    vvi teams;

    int cnt = 0;
    while (cnt < n && A[cnt].first <= n - cnt)
    {
        teams.push_back(vi());
        for (int d = 0; d < A[cnt].first; ++d)
            teams.back().push_back(A[cnt + d].second);
        cnt += A[cnt].first;
    }
    priority_queue<pii, vpii, greater<pii>> q;
    for (int i = 0; i < sz(teams); ++i)
        q.push({sz(teams[i]), i});

    while (cnt < n)
    {
        int size, team;
        tie(size, team) = q.top();
        q.pop();
        teams[team].push_back(A[cnt].second);
        ++size, ++cnt;
        q.push({size, team});
    }

    cout << sz(teams) << "\n";
    for (vi team : teams)
    {
        cout << sz(team);
        for (int p : team)
            cout << " " << p + 1;
        cout << "\n";
    }

    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 1 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 320 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 2372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2508 KB Output is correct
2 Correct 17 ms 2192 KB Output is correct
3 Correct 21 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 191 ms 18472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 251 ms 25140 KB Output is correct
2 Correct 299 ms 89844 KB Output is correct
3 Incorrect 228 ms 24964 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 271 ms 27724 KB Output is correct
2 Correct 179 ms 30808 KB Output is correct
3 Incorrect 227 ms 23708 KB Output isn't correct
4 Halted 0 ms 0 KB -