Submission #334712

#TimeUsernameProblemLanguageResultExecution timeMemory
334712nikatamlianiGift (IZhO18_nicegift)C++14
30 / 100
2052 ms158072 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5+10; #define ll long long int main() { int n, k; cin >> n >> k; set<pair<int,int>> s; for(int i = 1; i <= n; ++i) { int x; cin >> x; s.insert({-x, i}); } vector<vector<pair<int,int>>> answer; while(s.begin()->first < 0) { vector<pair<int,int>> v; for(pair<int,int> p : s) { v.push_back(p); if(v.size() == k) break; } for(pair<int,int> p : v) { s.erase(p); p.first++; if(p.first > 0) { cout << "-1\n"; return 0; } s.insert(p); } answer.push_back(v); } cout << answer.size() << '\n'; for(auto v : answer) { cout << 1 << ' '; for(pair<int,int> p : v) { cout << p.second << ' '; } cout << '\n'; } }

Compilation message (stderr)

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