답안 #787507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787507 2023-07-19T08:45:10 Z willychan Gift (IZhO18_nicegift) C++14
30 / 100
26 ms 4180 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds




int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n,k;cin>>n>>k;
	ll asum=0;
	vector<int> arr(n);
	int maxn = 0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		asum+=arr[i];
		maxn = max(maxn,arr[i]);
	}
	if(asum%k){
		cout<<-1<<"\n";
		return 0;
	}
	if(maxn>asum/k){
		cout<<-1<<"\n";
		return 0;
	}
	priority_queue<pair<int,int> > pq;
	for(int i=0;i<n;i++){
		pq.push({arr[i],i});
	}
	cout<<asum/k<<"\n";
	for(int t=0;t<asum/k;t++){
		cout<<1;
		vector<int> use;
		for(int i=0;i<k;i++){
			int p = pq.top().second;
			pq.pop();
			cout<<" "<<p+1;
			arr[p]--;
			use.push_back(p);
		}
		for(auto i : use){
			pq.push({arr[i],i});
		}
		cout<<"\n";
	}
	
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 1 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Correct 6 ms 340 KB n=14
10 Correct 3 ms 340 KB n=11
11 Correct 26 ms 1780 KB n=50000
12 Correct 21 ms 1748 KB n=50000
13 Correct 14 ms 556 KB n=10
14 Correct 17 ms 692 KB n=685
15 Correct 18 ms 772 KB n=623
16 Correct 10 ms 532 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 1 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Correct 6 ms 340 KB n=14
10 Correct 3 ms 340 KB n=11
11 Correct 26 ms 1780 KB n=50000
12 Correct 21 ms 1748 KB n=50000
13 Correct 14 ms 556 KB n=10
14 Correct 17 ms 692 KB n=685
15 Correct 18 ms 772 KB n=623
16 Correct 10 ms 532 KB n=973
17 Correct 18 ms 700 KB n=989
18 Correct 9 ms 444 KB n=563
19 Correct 15 ms 704 KB n=592
20 Correct 20 ms 724 KB n=938
21 Correct 14 ms 596 KB n=747
22 Correct 13 ms 592 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 4180 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 1 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Correct 6 ms 340 KB n=14
10 Correct 3 ms 340 KB n=11
11 Correct 26 ms 1780 KB n=50000
12 Correct 21 ms 1748 KB n=50000
13 Correct 14 ms 556 KB n=10
14 Correct 17 ms 692 KB n=685
15 Correct 18 ms 772 KB n=623
16 Correct 10 ms 532 KB n=973
17 Correct 18 ms 700 KB n=989
18 Correct 9 ms 444 KB n=563
19 Correct 15 ms 704 KB n=592
20 Correct 20 ms 724 KB n=938
21 Correct 14 ms 596 KB n=747
22 Correct 13 ms 592 KB n=991
23 Incorrect 10 ms 4180 KB Jury has the answer but participant has not
24 Halted 0 ms 0 KB -