Submission #874844

#TimeUsernameProblemLanguageResultExecution timeMemory
874844MatjazTeams (CEOI11_tea)C++14
0 / 100
2590 ms26808 KiB
// // 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...