Submission #905970

#TimeUsernameProblemLanguageResultExecution timeMemory
905970GrandTiger1729Teams (CEOI11_tea)C++17
0 / 100
312 ms35860 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> solve(int t, vector<pair<int, int>> a) { int n = a.size(); vector<vector<int>> ans; ans.emplace_back(); for (int i = 0; i < a[0].first; i++) { ans.back().push_back(a[i].second); } int l = a[0].first; for (int i = l; i < n; i++) { if (i - l >= a[l].first) { ans.emplace_back(); for (int j = l; j < i; j++) { ans.back().push_back(a[j].second); } l = i; } else if (i + a[i].first < l + a[l].first && ans.back().size() + i - l <= t) { for (int j = l; j < i; j++) { ans.back().push_back(a[j].second); } l = i; } } if (n - l >= a[l].first) { ans.emplace_back(); } for (int i = l; i < n; i++) { ans.back().push_back(a[i].second); } return ans; } int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { int x; cin >> x; a[i] = make_pair(x, i); } sort(a.begin(), a.end(), greater<>()); int l = a[0].first - 1, r = n; int t = solve(n, a).size(); while (l < r - 1) { int mid = (l + r) / 2; (solve(mid, a).size() == t ? r : l) = mid; } auto ans = solve(r, a); cout << ans.size() << '\n'; for (auto &res : ans) { cout << res.size() << ' '; for (int &i : res) { cout << i + 1 << ' '; } cout << '\n'; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'std::vector<std::vector<int> > solve(int, std::vector<std::pair<int, int> >)':
tea.cpp:25:79: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         else if (i + a[i].first < l + a[l].first && ans.back().size() + i - l <= t)
      |                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
tea.cpp: In function 'int main()':
tea.cpp:63:31: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |         (solve(mid, a).size() == t ? r : l) = mid;
      |          ~~~~~~~~~~~~~~~~~~~~~^~~~
#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...