Submission #961247

# Submission time Handle Problem Language Result Execution time Memory
961247 2024-04-11T18:46:04 Z pragmatist Gift (IZhO18_nicegift) C++17
0 / 100
18 ms 4312 KB
#include<bits/stdc++.h>

using namespace std;

const int N = (int)1e6+7;

int n, k, a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cin >> n >> k;
	long long tot = 0;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		tot += a[i];
	}    
	sort(a+1, a+1+n);
	if(tot%k) {
		cout << "-1\n";
		return 0;
	}
	if(a[n]>tot/2) {
		cout << "-1\n";
		return 0;
	}
	cout << tot/k << "\n";
	set<pair<int, int> > s;
	for(int i = 1; i <= n; ++i) {
		s.insert({a[i], i});
	}
	for(int i = 1; i <= tot/k; ++i) {
		vector<int> cur;
		for(int j = 0; j < k; ++j) {
			auto it = s.begin();
			cur.push_back(it->second);
			s.erase(it);
		}
		cout << "1 ";
		for(auto id : cur) {
			cout << id << ' ';
		}
		cout << "\n";
		for(auto id : cur) {
			a[id]--;
			if(a[id]>0) {
				s.insert({a[id], id});
			}
		}
	}
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 4312 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -