답안 #484827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484827 2021-11-05T14:56:39 Z luka1234 Gift (IZhO18_nicegift) C++14
18 / 100
237 ms 47152 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int n,m;
set<pair<int,int> > s;
int a[1000001];
vector<vector<int> > ans;
int sum=0;
int main(){
	cin>>n>>m;
	for(int k=1;k<=n;k++){
		cin>>a[k];
		s.insert({a[k],k});
		sum+=a[k];
	}
	if(sum%2==1){
		cout<<-1;
		return 0;
	}
	int bolo=(*s.rbegin()).ff;
	if(bolo>(sum/2)){
		cout<<-1;
		return 0;
	}
	while(!s.empty()){
		vector<pair<int,int> > chamateba;
		int sz=s.size();
		while(s.size()>(sz-m)){
			pair<int,int> f=*s.rbegin();
			s.erase(*s.rbegin());
			chamateba.push_back(f);
		}
		vector<int> ans1;
		ans1.push_back(1);
		for(int k=0;k<chamateba.size();k++){
			pair<int,int> f=chamateba[k];
			ans1.push_back(f.ss);
			f.ff--;
			if(f.ff!=0)
			   s.insert(f);
		}
		ans.push_back(ans1);
	}
	cout<<ans.size()<<"\n";
	for(int k=0;k<ans.size();k++){
		for(int i=0;i<ans[k].size();i++){
			cout<<ans[k][i]<<' ';
		}
		cout<<"\n";
	}
    return 0;
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:30:17: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   while(s.size()>(sz-m)){
      |         ~~~~~~~~^~~~~~~
nicegift.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(int k=0;k<chamateba.size();k++){
      |               ~^~~~~~~~~~~~~~~~~
nicegift.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |  for(int k=0;k<ans.size();k++){
      |              ~^~~~~~~~~~~
nicegift.cpp:48:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for(int i=0;i<ans[k].size();i++){
      |               ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 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 204 KB n=5
8 Correct 0 ms 204 KB n=8
9 Correct 9 ms 1136 KB n=14
10 Correct 6 ms 844 KB n=11
11 Correct 52 ms 5364 KB n=50000
12 Correct 61 ms 5552 KB n=50000
13 Correct 31 ms 3392 KB n=10
14 Correct 32 ms 3064 KB n=685
15 Correct 35 ms 3316 KB n=623
16 Correct 20 ms 1952 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 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 204 KB n=5
8 Correct 0 ms 204 KB n=8
9 Correct 9 ms 1136 KB n=14
10 Correct 6 ms 844 KB n=11
11 Correct 52 ms 5364 KB n=50000
12 Correct 61 ms 5552 KB n=50000
13 Correct 31 ms 3392 KB n=10
14 Correct 32 ms 3064 KB n=685
15 Correct 35 ms 3316 KB n=623
16 Correct 20 ms 1952 KB n=973
17 Correct 34 ms 2448 KB n=989
18 Correct 19 ms 960 KB n=563
19 Incorrect 1 ms 332 KB Jury has the answer but participant has not
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 237 ms 47152 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 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 204 KB n=5
8 Correct 0 ms 204 KB n=8
9 Correct 9 ms 1136 KB n=14
10 Correct 6 ms 844 KB n=11
11 Correct 52 ms 5364 KB n=50000
12 Correct 61 ms 5552 KB n=50000
13 Correct 31 ms 3392 KB n=10
14 Correct 32 ms 3064 KB n=685
15 Correct 35 ms 3316 KB n=623
16 Correct 20 ms 1952 KB n=973
17 Correct 34 ms 2448 KB n=989
18 Correct 19 ms 960 KB n=563
19 Incorrect 1 ms 332 KB Jury has the answer but participant has not
20 Halted 0 ms 0 KB -