Submission #334710

# Submission time Handle Problem Language Result Execution time Memory
334710 2020-12-09T21:03:37 Z nikatamliani Gift (IZhO18_nicegift) C++14
0 / 100
2000 ms 160780 KB
#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 << '\n';
	}
}

Compilation message

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 time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 160780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -