Submission #495218

#TimeUsernameProblemLanguageResultExecution timeMemory
495218NalrimetGift (IZhO18_nicegift)C++17
30 / 100
2037 ms524292 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int inf = 1000000000; #define F first #define S second #define pb push_back priority_queue<pair<int, int>> q; int n, k, a[N]; vector<int> v; vector<vector<int>> ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for(int i = 1; i <= n; ++i){ cin >> a[i]; q.push({a[i], i}); } while(!q.empty()){ if(q.size() < k){ cout << -1; exit(0); } for(int i = 1; i <= k; ++i){ v.push_back(q.top().S); q.pop(); } ans.pb(v); for(int i = 0; i < k; ++i){ a[v[i]]--; if(a[v[i]] != 0) q.push({a[v[i]], v[i]}); } v.clear(); } cout << ans.size() << '\n'; for(auto to : ans){ cout << 1 << ' '; for(auto to1 : to){ cout << to1 << ' '; } cout << '\n'; } return 0; }

Compilation message (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:32:21: warning: comparison of integer expressions of different signedness: 'std::priority_queue<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |         if(q.size() < k){
      |            ~~~~~~~~~^~~
#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...