Submission #961246

# Submission time Handle Problem Language Result Execution time Memory
961246 2024-04-11T18:45:34 Z pragmatist Gift (IZhO18_nicegift) C++17
0 / 100
27 ms 4184 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]--;
			s.insert({a[id], id});
		}
	}
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 4184 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 348 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -