답안 #961253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961253 2024-04-11T18:51:33 Z pragmatist Gift (IZhO18_nicegift) C++17
30 / 100
30 ms 5780 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;
	int mx = 0;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		tot += a[i];
		mx = max(mx, a[i]);
	}    
	if(tot%k) {
		cout << "-1\n";
		return 0;
	}
	if(mx>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.end();
			cur.push_back(it->second);
			s.erase(it);
		}
		cout << "1 ";
		for(auto id : cur) {
			assert(a[id]>0);
			cout << id << ' ';
		}
		cout << "\n";
		for(auto id : cur) {
			a[id]--;
			if(a[id]>0) {
				s.insert({a[id], id});
			}
		}
	}
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 1 ms 348 KB n=3
3 Correct 0 ms 344 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 0 ms 348 KB n=4
6 Correct 0 ms 348 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 1 ms 348 KB n=3
3 Correct 0 ms 344 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 0 ms 348 KB n=4
6 Correct 0 ms 348 KB n=2
7 Correct 0 ms 348 KB n=5
8 Correct 0 ms 348 KB n=8
9 Correct 4 ms 348 KB n=14
10 Correct 3 ms 600 KB n=11
11 Correct 22 ms 5780 KB n=50000
12 Correct 30 ms 5748 KB n=50000
13 Correct 14 ms 856 KB n=10
14 Correct 15 ms 728 KB n=685
15 Correct 16 ms 836 KB n=623
16 Correct 9 ms 600 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 1 ms 348 KB n=3
3 Correct 0 ms 344 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 0 ms 348 KB n=4
6 Correct 0 ms 348 KB n=2
7 Correct 0 ms 348 KB n=5
8 Correct 0 ms 348 KB n=8
9 Correct 4 ms 348 KB n=14
10 Correct 3 ms 600 KB n=11
11 Correct 22 ms 5780 KB n=50000
12 Correct 30 ms 5748 KB n=50000
13 Correct 14 ms 856 KB n=10
14 Correct 15 ms 728 KB n=685
15 Correct 16 ms 836 KB n=623
16 Correct 9 ms 600 KB n=973
17 Correct 17 ms 860 KB n=989
18 Correct 8 ms 600 KB n=563
19 Correct 21 ms 860 KB n=592
20 Correct 14 ms 860 KB n=938
21 Correct 11 ms 604 KB n=747
22 Correct 13 ms 600 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 344 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n=4
2 Correct 1 ms 348 KB n=3
3 Correct 0 ms 344 KB n=3
4 Correct 0 ms 348 KB n=4
5 Correct 0 ms 348 KB n=4
6 Correct 0 ms 348 KB n=2
7 Correct 0 ms 348 KB n=5
8 Correct 0 ms 348 KB n=8
9 Correct 4 ms 348 KB n=14
10 Correct 3 ms 600 KB n=11
11 Correct 22 ms 5780 KB n=50000
12 Correct 30 ms 5748 KB n=50000
13 Correct 14 ms 856 KB n=10
14 Correct 15 ms 728 KB n=685
15 Correct 16 ms 836 KB n=623
16 Correct 9 ms 600 KB n=973
17 Correct 17 ms 860 KB n=989
18 Correct 8 ms 600 KB n=563
19 Correct 21 ms 860 KB n=592
20 Correct 14 ms 860 KB n=938
21 Correct 11 ms 604 KB n=747
22 Correct 13 ms 600 KB n=991
23 Incorrect 7 ms 344 KB Jury has the answer but participant has not
24 Halted 0 ms 0 KB -