Submission #875419

# Submission time Handle Problem Language Result Execution time Memory
875419 2023-11-19T16:08:52 Z gutzzy Teams (CEOI11_tea) C++14
0 / 100
440 ms 37380 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);
        }
        else if(pos+a[pos].first==n){
            vector<pair<int,int>> temp(a.begin()+pos,a.end());
            teams.push_back(temp);
        }
        else{
            rest = vector<pair<int,int>>(a.begin()+pos,a.end());
        }
        pos+=a[pos].first;
    }
    
    /*
    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;
    */
    
    if(rest.size()!=0){
        reverse(rest.begin(),rest.end());
        pos = 0;
        int l_rest = rest.size();
        vector<pair<int,int>> rest2;
        while(pos<l_rest){
            if(pos+rest[pos].first<l_rest){
                vector<pair<int,int>> temp(rest.begin()+pos,rest.begin()+pos+rest[pos].first);
                teams.push_back(temp);
            }
            else if(pos+rest[pos].first==l_rest){
                vector<pair<int,int>> temp(rest.begin()+pos,rest.end());
                teams.push_back(temp);
            }
            else{
                vector<pair<int,int>> rest2(rest.begin()+pos,rest.end());
            }
            pos+=rest[pos].first;
        }
        for(auto r:rest2){
            int best = 0;
            int cur_best = 1e9;
            int i=0;
            for(auto team:teams){
                if(team.size()>=r.first-1 and 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;
}

Compilation message

tea.cpp: In function 'int main()':
tea.cpp:72:31: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |                 if(team.size()>=r.first-1 and team.size()<cur_best){
      |                    ~~~~~~~~~~~^~~~~~~~~~~
tea.cpp:72:58: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |                 if(team.size()>=r.first-1 and team.size()<cur_best){
      |                                               ~~~~~~~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 500 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 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 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 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 2756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 248 ms 21072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 366 ms 29804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 440 ms 37380 KB Output isn't correct
2 Halted 0 ms 0 KB -