Submission #530162

#TimeUsernameProblemLanguageResultExecution timeMemory
530162LFFBTeams (CEOI11_tea)C++14
0 / 100
263 ms20968 KiB
#include <iostream> #include <vector> #include <algorithm> const int MAX_N = 1000000 + 10; int n; std::pair<int, int> input[MAX_N]; bool sortingFunction(std::pair<int, int> a, std::pair<int, int> b) { return a.first > b.first; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); input[i] = std::make_pair(x, i); } std::sort(input, input + n, sortingFunction); std::vector<int> teamSize; std::vector<std::vector<int>> team; std::vector<int> minimum; int index = 0; int remaining = n; teamSize.push_back(1); team.push_back(std::vector<int>()); team[0].push_back(input[0].second); minimum.push_back(input[0].first); for (int i = 1; i < n; i++) { remaining--; if (minimum[index] > teamSize[index]) { teamSize[index]++; team[index].push_back(input[i].second); } else if (remaining >= input[i].first) { teamSize.push_back(1); team.push_back(std::vector<int>()); minimum.push_back(input[i].first); index++; team[index].push_back(input[i].second); } else { teamSize[index]++; team[index].push_back(input[i].second); } } printf("%d\n", (int)team.size()); for (std::vector<int> t : team) { printf("%d ", (int)t.size()); for (int x : t) printf("%d ", x + 1); printf("\n"); } }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
tea.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
#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...