답안 #377950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377950 2021-03-15T15:31:15 Z SeDunion Gift (IZhO18_nicegift) C++17
7 / 100
2000 ms 29676 KB
#include<bits/stdc++.h>
#ifndef LOCAL
#define cerr if(false)cerr
#endif // LOCAL
using namespace std;
using ll = long long;
const int N = 1e6 + 66;

pair<ll,int>a[N];
vector<vector<int>>ans;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 1 ; i <= n ; ++ i) {
		cin >> a[i].first; a[i].second = i;
	}
	bool ok = 1;
	while (1) {
		sort(a + 1, a + 1 + n);
		reverse(a + 1, a + 1 + n);
		if (a[1].first == 0) break;
		ans.push_back(vector<int>(k));
		for (int i = 1 ; i <= k ; ++ i) {
			if (a[i].first <= 0) {
				ok = 0;
				break;
			}
			a[i].first--;
			ans.back()[i - 1] = a[i].second;
		}
	}
	if (ok == 0) {
		cout << "-1";
		return 0;
	}
	cout << ans.size() << "\n";
	for (auto vec : ans) {
		cout << "1 ";
		for (int i : vec) cout << i << " ";
		cout << "\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 364 KB n=5
8 Correct 9 ms 3488 KB n=8
9 Correct 8 ms 1192 KB n=14
10 Correct 5 ms 1004 KB n=11
11 Execution timed out 2055 ms 1684 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 364 KB n=5
8 Correct 9 ms 3488 KB n=8
9 Correct 8 ms 1192 KB n=14
10 Correct 5 ms 1004 KB n=11
11 Execution timed out 2055 ms 1684 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2066 ms 29676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB n=4
2 Correct 1 ms 364 KB n=3
3 Correct 1 ms 364 KB n=3
4 Correct 1 ms 364 KB n=4
5 Correct 1 ms 364 KB n=4
6 Correct 1 ms 364 KB n=2
7 Correct 1 ms 364 KB n=5
8 Correct 9 ms 3488 KB n=8
9 Correct 8 ms 1192 KB n=14
10 Correct 5 ms 1004 KB n=11
11 Execution timed out 2055 ms 1684 KB Time limit exceeded
12 Halted 0 ms 0 KB -