Submission #875428

# Submission time Handle Problem Language Result Execution time Memory
875428 2023-11-19T16:44:20 Z gutzzy Teams (CEOI11_tea) C++14
50 / 100
2500 ms 30512 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i].first;
        a[i].second = i+1;
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int pos = 0;
    vector<vector<pair<int,int>>> teams;
    vector<pair<int,int>> rest;
    while(pos<n){
        if(pos+a[pos].first<n){
            vector<pair<int,int>> temp(a.begin()+pos,a.begin()+pos+a[pos].first);
            teams.push_back(temp);
            pos+=a[pos].first;
        }
        else if(pos+a[pos].first==n){
            vector<pair<int,int>> temp(a.begin()+pos,a.end());
            teams.push_back(temp);
            pos+=a[pos].first;
        }
        else{
            rest.push_back(a[pos]);
            pos++;
        }
    }
    
    /*
    cout << "teams: "<<endl;
    for(auto t:teams){
        for(auto m:t){
            cout << m.first << " " << m.second << endl;
        }
        cout << endl;
    }
    cout << "rest: "<<endl;
    for(auto m:rest){
        cout << m.first << " " << m.second << endl;
    }
    cout << "ans: "<<endl;
    */
    
    for(auto r:rest){
        int best = 0;
        int cur_best = 1e9;
        int i=0;
        for(auto team:teams){
            if((int) team.size()>=r.first-1 and (int) team.size()<cur_best){
                cur_best = team.size();
                best = i;
            }
            i++;
        }
        teams[best].push_back(r);
    }
    
    // print answer
    
    cout << teams.size() << endl;
        for(auto team:teams){
            cout << team.size() << " ";
            for(auto m:team) cout << m.second << " ";
            cout << endl;
        }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 3 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 264 ms 2508 KB Output is correct
2 Correct 25 ms 2240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 349 ms 3280 KB Output is correct
2 Correct 29 ms 2160 KB Output is correct
3 Correct 126 ms 2360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1887 ms 18444 KB Output is correct
2 Correct 254 ms 20236 KB Output is correct
3 Execution timed out 2528 ms 17944 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2603 ms 18580 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2541 ms 30512 KB Time limit exceeded
2 Halted 0 ms 0 KB -