Submission #787502

# Submission time Handle Problem Language Result Execution time Memory
787502 2023-07-19T08:41:13 Z willychan Gift (IZhO18_nicegift) C++14
7 / 100
132 ms 27624 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;
	set<int> s;
	int g = 0;
	ll asum=0;
	for(int i=1;i<n;i++){
		g = (g+k)%n;	
		s.insert(g);
	}
	vector<int> arr(n);
	int sum = 0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum = (sum+arr[i])%n;
		asum+=arr[i];
	}
	if(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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 1 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 1 ms 212 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 1 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 1 ms 212 KB n=2
7 Correct 1 ms 212 KB n=5
8 Incorrect 9 ms 448 KB Taken too much stones from the heap
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 1 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 1 ms 212 KB n=2
7 Correct 1 ms 212 KB n=5
8 Incorrect 9 ms 448 KB Taken too much stones from the heap
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 27624 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 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 1 ms 212 KB n=4
5 Correct 1 ms 212 KB n=4
6 Correct 1 ms 212 KB n=2
7 Correct 1 ms 212 KB n=5
8 Incorrect 9 ms 448 KB Taken too much stones from the heap
9 Halted 0 ms 0 KB -