Submission #483401

# Submission time Handle Problem Language Result Execution time Memory
483401 2021-10-29T07:37:26 Z mosiashvililuka Gift (IZhO18_nicegift) C++14
30 / 100
2000 ms 254224 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,k,f[1000009];
vector <vector <long long> > ans;
vector <long long> vv;
multiset <pair <long long, long long> > s;
multiset <pair <long long, long long> >::iterator it;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>k;zx=0;
	for(i=1; i<=a; i++){
		cin>>f[i];
		s.insert(make_pair(f[i],i));
		zx+=f[i];
	}
	if(zx%k!=0){
		cout<<-1;exit(0);
	}
	while(s.size()>=k){
		c=1;it=s.end();vv.clear();
		while(c<=k){
			it--;
			vv.push_back((*it).second);c++;
		}
		ans.push_back(vv);c=1;
		while(c<=k){
			it=s.end();it--;
			s.erase(it);c++;
		}
		for(i=0; i<vv.size(); i++){
			f[vv[i]]--;
			if(f[vv[i]]>0) s.insert(make_pair(f[vv[i]],vv[i]));
		}
	}
	if(s.size()!=0){
		cout<<-1;exit(0);
	}
	cout<<ans.size()<<"\n";
	for(i=0; i<ans.size(); i++){
		cout<<"1 ";
		for(j=0; j<k; j++){
			cout<<ans[i][j]<<" ";
		}
		cout<<"\n";
	}
	return 0;
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:19:16: warning: comparison of integer expressions of different signedness: 'std::multiset<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   19 |  while(s.size()>=k){
      |        ~~~~~~~~^~~
nicegift.cpp:30:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(i=0; i<vv.size(); i++){
      |            ~^~~~~~~~~~
nicegift.cpp:39:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(i=0; i<ans.size(); i++){
      |           ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 320 KB n=5
8 Correct 2 ms 972 KB n=8
9 Correct 5 ms 1144 KB n=14
10 Correct 4 ms 972 KB n=11
11 Correct 31 ms 6528 KB n=50000
12 Correct 33 ms 6632 KB n=50000
13 Correct 17 ms 3456 KB n=10
14 Correct 20 ms 3064 KB n=685
15 Correct 22 ms 3288 KB n=623
16 Correct 12 ms 2044 KB n=973
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 320 KB n=5
8 Correct 2 ms 972 KB n=8
9 Correct 5 ms 1144 KB n=14
10 Correct 4 ms 972 KB n=11
11 Correct 31 ms 6528 KB n=50000
12 Correct 33 ms 6632 KB n=50000
13 Correct 17 ms 3456 KB n=10
14 Correct 20 ms 3064 KB n=685
15 Correct 22 ms 3288 KB n=623
16 Correct 12 ms 2044 KB n=973
17 Correct 24 ms 2536 KB n=989
18 Correct 12 ms 1228 KB n=563
19 Correct 21 ms 1612 KB n=592
20 Correct 18 ms 1668 KB n=938
21 Correct 14 ms 1452 KB n=747
22 Correct 15 ms 1484 KB n=991
# Verdict Execution time Memory Grader output
1 Execution timed out 2100 ms 254224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 320 KB n=5
8 Correct 2 ms 972 KB n=8
9 Correct 5 ms 1144 KB n=14
10 Correct 4 ms 972 KB n=11
11 Correct 31 ms 6528 KB n=50000
12 Correct 33 ms 6632 KB n=50000
13 Correct 17 ms 3456 KB n=10
14 Correct 20 ms 3064 KB n=685
15 Correct 22 ms 3288 KB n=623
16 Correct 12 ms 2044 KB n=973
17 Correct 24 ms 2536 KB n=989
18 Correct 12 ms 1228 KB n=563
19 Correct 21 ms 1612 KB n=592
20 Correct 18 ms 1668 KB n=938
21 Correct 14 ms 1452 KB n=747
22 Correct 15 ms 1484 KB n=991
23 Execution timed out 2100 ms 254224 KB Time limit exceeded
24 Halted 0 ms 0 KB -