답안 #1111397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111397 2024-11-12T08:08:06 Z freefire123 Teams (CEOI11_tea) C++14
30 / 100
265 ms 97184 KB
#include <bits/stdc++.h>
#define ii pair < int , int >
#define fi first
#define se second
#define int long long
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)

using namespace std;

void maximize(int &A, int B)
{
    if(A < B) A = B;
    return;
}

void minimize(int &A, int B)
{
    if(A > B) A = B;
    return;
}

const int N = 1e6 + 5;
const int mod = 1e9 + 7;

int n;

ii a[N];

vector < int > team[N];

priority_queue < ii , vector < ii > , greater < ii > > q;


bool cmp(ii a, ii b)
{
    return a.fi > b.fi;
}


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n){
        cin >> a[i].fi;
        a[i].se = i;
    }
    sort(a + 1, a + n + 1, cmp);
    int cnt = 0, save = n + 1;
    FOR(i, 1, n){
        if(i + a[i].fi - 1 > n){
            save = i;
            break;
        }
        cnt++;
        for(int j = i; j <= i + a[i].fi - 1; j++){
            team[cnt].push_back(a[j].se);
        }
        i = i + a[i].fi - 1;
    }
    FOR(i, 1, cnt){
        q.push(ii((int)team[i].size(), i));
    }
    FOR(i, save, n){
        int I = q.top().se;
        q.pop();
        team[I].push_back(a[i].se);
        q.push(ii((int)team[I].size(), I));
    }
    cout << cnt << '\n';
    FOR(i, 1, cnt){
        cout << (int)team[i].size() << " ";
        for(int &v : team[i]){
            cout << v << " ";
        }
        cout << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 25168 KB Output is correct
2 Correct 6 ms 25228 KB Output is correct
3 Correct 5 ms 25168 KB Output is correct
4 Correct 5 ms 25168 KB Output is correct
5 Correct 7 ms 25168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 25168 KB Output is correct
2 Incorrect 5 ms 25168 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 25168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 25168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 25168 KB Output is correct
2 Correct 6 ms 25168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 26456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 28496 KB Output is correct
2 Correct 21 ms 26704 KB Output is correct
3 Correct 24 ms 28496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 132 ms 49084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 54340 KB Output is correct
2 Correct 265 ms 97184 KB Output is correct
3 Incorrect 165 ms 59592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 190 ms 54836 KB Output is correct
2 Correct 167 ms 54608 KB Output is correct
3 Incorrect 169 ms 55976 KB Output isn't correct
4 Halted 0 ms 0 KB -