답안 #875446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875446 2023-11-19T17:37:55 Z ElenaBM Teams (CEOI11_tea) C++17
0 / 100
469 ms 262144 KB
#include <bits/stdc++.h>
#define x first
#define y second
 
using namespace std;
 
int main()
{
    int n;
    cin>> n;
    vector<int>a, s(1);
    vector<pair<int,int>>v(n);
    vector<vector<int>>teams(1);
    for (int i = 0; i < n; ++i){
        int u;
        cin>> u;
        v[i] = {u, i+1};
    }
    sort(v.begin(), v.end(), greater());
    teams[0].push_back(v[0].y);
    s[0] = v[0].x -1;
    int cur = 0;
    for (int i = 1; i <n; ++i){
        if (s[cur] > 0){
            teams[cur].push_back(v[i].y);
            s[cur]--;
        }
        else{
            if(v[i].x-1 > n - i){//si el tamaño requerido por el mayor jugador es mayor a la cantidad de jugadores por emparejar --> prevenir
                for (int u = i; u < n; ++i){
                    teams[cur].push_back(v[u].y);
                }
                break;
            } 
            teams.push_back(vector<int>());
            cur++;
            teams[cur].push_back(v[i].y);
            s.push_back(v[i].x-1);
        }
    }
    cout<< (int)teams.size() << '\n';
    for (int i = 0; i < (int) teams.size(); ++i){
        cout<< (int) teams[i].size()<< ' ';
        for (int j = 0; j < (int)teams[i].size(); ++j){
            cout<< teams[i][j]<< ' ';
        }
        cout<< '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 189 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 144 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 144 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 150 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 171 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 169 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 343 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 429 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 469 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -