Submission #829240

#TimeUsernameProblemLanguageResultExecution timeMemory
829240HanksburgerCookies (JOI23_cookies)C++17
7 / 100
66 ms1152 KiB
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > vec; vector<vector<int> > ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k, sum=0; cin >> n; for (int i=0; i<n; i++) { int x; cin >> x; vec.push_back({x, i+1}); } cin >> m >> k; for (int i=0; i<n; i++) sum+=vec[i].first; if (sum%k) { cout << -1; return 0; } for (int i=0; i<sum/k; i++) { sort(vec.begin(), vec.end(), greater<pair<int, int> >()); vector<int> tmp; for (int j=0; j<k; j++) { if (!vec[j].first) { cout << -1; return 0; } vec[j].first--; tmp.push_back(vec[j].second); } ans.push_back(tmp); } cout << ans.size() << '\n'; for (int i=0; i<ans.size(); i++) { cout << ans[i].size() << ' '; for (int j=0; j<ans[i].size(); j++) cout << ans[i][j] << ' '; cout << '\n'; } }

Compilation message (stderr)

cookies.cpp: In function 'int main()':
cookies.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i=0; i<ans.size(); i++)
      |                   ~^~~~~~~~~~~
cookies.cpp:46:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for (int j=0; j<ans[i].size(); j++)
      |                       ~^~~~~~~~~~~~~~
#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...