Submission #370026

#TimeUsernameProblemLanguageResultExecution timeMemory
370026ijxjdjdTeams (CEOI11_tea)C++14
30 / 100
409 ms74920 KiB
#include <bits/stdc++.h> #define FR(i, N) for (int i = 0; i < int(N); i++) #define all(x) begin(x), end(x) using namespace std; using ll = long long; int main() { cin.tie(0); cin.sync_with_stdio(0); int N; cin >> N; vector<pair<int, int>> vec; FR(i, N) { int a; cin >> a; vec.emplace_back(a, i); } sort(all(vec)); vector<vector<int>> teams; for (int j = N-1; j >= 0;) { int k = vec[j].first; if (j >= k-1) { teams.push_back({}); while (k--> 0) { teams.back().push_back(vec[j].second); j--; } } else { while (k-->0 && j >= 0) { int mn = 100000; int mnI = -1; for (int c = 0; c < teams.size(); c++) { if (teams[c].size() < mn) { mn = teams[c].size(); mnI = c; } } teams[mnI].push_back(vec[j].second); j--; } } } cout << teams.size() << '\n'; for (auto& a : teams) { cout << a.size() << " "; for (int j : a) { cout << j+1<< " "; } cout << '\n'; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:35:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |                 for (int c = 0; c < teams.size(); c++) {
      |                                 ~~^~~~~~~~~~~~~~
tea.cpp:36:41: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |                     if (teams[c].size() < mn) {
      |                         ~~~~~~~~~~~~~~~~^~~~
#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...