답안 #1111400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1111400 2024-11-12T08:10:08 Z freefire123 Teams (CEOI11_tea) C++14
30 / 100
242 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 5 ms 25168 KB Output is correct
3 Correct 5 ms 25168 KB Output is correct
4 Correct 5 ms 25168 KB Output is correct
5 Correct 6 ms 25336 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 5 ms 25168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 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 22 ms 28496 KB Output is correct
2 Correct 17 ms 26704 KB Output is correct
3 Correct 21 ms 28496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 167 ms 49236 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 195 ms 54448 KB Output is correct
2 Correct 242 ms 97184 KB Output is correct
3 Incorrect 153 ms 59596 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 178 ms 54836 KB Output is correct
2 Correct 152 ms 54704 KB Output is correct
3 Incorrect 185 ms 55724 KB Output isn't correct
4 Halted 0 ms 0 KB -