Submission #874844

# Submission time Handle Problem Language Result Execution time Memory
874844 2023-11-17T23:42:11 Z Matjaz Teams (CEOI11_tea) C++14
0 / 100
2500 ms 26808 KB
//
//  CEOI11_TEA.cpp
//  
//
//  Created by Matjaz Leonardis on 06/11/2023.
//

#include <iostream>
#include <vector>
#include <algorithm>
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());
    
    vector<pair<int,int> > best(N); //largest number of teams
    vector<int> choice(N, -2);
    
    for (int i=0;i<N;i++){
        int most_teams = 0;
        int biggest_size = N + 1;
        
        if (a[i].first <= i + 1){
            most_teams = 1;
            biggest_size = i + 1;
            choice[i] = -1;
            
        }
        
        for (int j=i-1;j>=0;j--){
            if (i - j < a[i].first) continue;
            
            if (best[j].first + 1 == most_teams && biggest_size > max(best[j].second, i - j) ){
                biggest_size = max(best[j].second, i - j);
                choice[i] = j;
            }
            
            if (best[j].first + 1 > most_teams){
                biggest_size = best[j].first + 1;
                biggest_size = max(best[j].second, i - j);
                choice[i] = j;
            }
        }
        
        best[i] = make_pair(most_teams, biggest_size);
        
    }
    cout << best[N-1].first << endl;
    int tmp = N - 1;
    while (tmp >= 0){
        cout << tmp - choice[tmp];
        for (int i=tmp;i>choice[tmp];i--) cout << " " << a[i].second;
        cout << endl;
        tmp = choice[tmp];
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Expected EOF
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 348 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 452 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2504 ms 2464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2590 ms 2640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2508 ms 18668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2559 ms 25788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2528 ms 26808 KB Time limit exceeded
2 Halted 0 ms 0 KB -