Submission #1107929

# Submission time Handle Problem Language Result Execution time Memory
1107929 2024-11-02T11:34:35 Z stdfloat Gift (IZhO18_nicegift) C++17
7 / 100
2000 ms 8272 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define sz(v)	(int)(v).size()
#define all(v)	(v).begin(), (v).end()

#define ff	first
#define ss	second
#define pii	pair<int, int>

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, k;
	cin >> n >> k;

	ll sm = 0;
	pair<int, int> p[n];
	for (int i = 0; i < n; i++) {
		cin >> p[i].ff; p[i].ss = i;
	
		sm += p[i].ff;
	}

	if (sm % k) return cout << -1, 0;
	
	sort(p, p + n);
	
	vector<vector<int>> ans;
	while (p[n - 1].ff) {
		ans.push_back({});
		for (int i = n - 1; i >= n - k; i--) {
			// assert(p[i].ff);
			if (!p[i].ff) return cout << -1, 0;
			p[i].ff--;
			ans.back().push_back(p[i].ss);
		}

		sort(p, p + n);
	}

	cout << sz(ans) << '\n';
	for (auto i : ans) {
		cout << "1 ";
		for (auto j : i)
			cout << j + 1 << ' ';
		cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 504 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 508 KB n=4
6 Correct 1 ms 336 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 504 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 508 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 2 ms 1104 KB n=8
9 Correct 5 ms 1164 KB n=14
10 Correct 4 ms 908 KB n=11
11 Execution timed out 2073 ms 936 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 504 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 508 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 2 ms 1104 KB n=8
9 Correct 5 ms 1164 KB n=14
10 Correct 4 ms 908 KB n=11
11 Execution timed out 2073 ms 936 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 8272 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB n=4
2 Correct 1 ms 336 KB n=3
3 Correct 1 ms 504 KB n=3
4 Correct 1 ms 336 KB n=4
5 Correct 1 ms 508 KB n=4
6 Correct 1 ms 336 KB n=2
7 Correct 1 ms 336 KB n=5
8 Correct 2 ms 1104 KB n=8
9 Correct 5 ms 1164 KB n=14
10 Correct 4 ms 908 KB n=11
11 Execution timed out 2073 ms 936 KB Time limit exceeded
12 Halted 0 ms 0 KB -