Submission #334711

#TimeUsernameProblemLanguageResultExecution timeMemory
334711nikatamlianiGift (IZhO18_nicegift)C++14
0 / 100
2071 ms159368 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) { for(pair<int,int> p : v) { cout << p.second << ' '; } cout << "1\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...