Submission #1107933

# Submission time Handle Problem Language Result Execution time Memory
1107933 2024-11-02T11:46:43 Z stdfloat Gift (IZhO18_nicegift) C++17
0 / 100
93 ms 17224 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;

	vector<int> a(n);
	for (auto &i : a)
		cin >> i;

	if (n % k) return cout << -1, 0;

	cout << n / k << '\n';
	for (int i = 1; i <= n; i += k) {
		cout << a[0] << ' ';
		for (int j = i; j < i + k; j++)
			cout << j << ' ';
		cout << '\n';
	}

	return 0;

	ll sm = 0;
	set<pii> s;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;

		sm += x;
		s.insert({x, i});
	}

	if (sm % k) return cout << -1, 0;
	
	vector<vector<int>> ans;
	while (!s.empty()) {
		if (sz(s) < k) return cout << -1, 0;

		vector<pii> v;
		ans.push_back({});
		for (int i = 0; i < k; i++) {
			auto t = --s.end();
		
			ans.back().push_back((*t).ss);
			if (1 < (*t).ff) v.push_back({(*t).ff - 1, (*t).ss});
			
			s.erase(t);
		}

		for (auto i : v)
			s.insert(i);
	}

	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 Incorrect 1 ms 336 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 17224 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Not all heaps are empty in the end
2 Halted 0 ms 0 KB -