Submission #738264

# Submission time Handle Problem Language Result Execution time Memory
738264 2023-05-08T11:00:34 Z MrAndria Table Tennis (info1cup20_tabletennis) C++14
35 / 100
3000 ms 21660 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
long long n,k,sum,ans,a[1000005];
vector <long long> v;
map <long long,long long> mp;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n+k;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(k==1){
		for(int i=1;i<=n+k;i++){
			mp.clear();
			for(int j=1;j<=n+k;j++){
				mp[a[j]]++;
			}
			ans=0;
			mp[a[i]]--;
			for(int j=1;j<=n+k;j++){
				if(j!=i){
					if(mp[((sum-a[i])/(n/2))-a[j]]>=1 and mp[a[j]]>=1){
						mp[((sum-a[i])/(n/2))-a[j]]--;
						ans++;
						mp[a[j]]--;
					}
				}
			}
			if(ans==(n/2)){
				for(int j=1;j<=n+k;j++){
					if(j!=i){
						v.pb(a[j]);
					}
				}
				sort(v.begin(),v.end());
				for(int j=0;j<v.size();j++){
					cout<<v[j]<<" ";
				}
				cout<<endl;
				return 0;
			}
			
		}
	}else{
		for(int i=1;i<=n+k;i++){
			for(int j=1;j<=n+k;j++){
				if(i!=j){
					mp.clear();
					v.clear();
					v.pb(a[i]);
					v.pb(a[j]);
					
					for(int l=1;l<=n+k;l++){
						mp[a[l]]++;
					}
					mp[a[j]]--;
					mp[a[i]]--;
					ans=0;
					for(int l=1;l<=n+k;l++){
						if(l!=j and l!=i){
							if(mp[a[i]+a[j]-a[l]]>=1 and mp[a[l]]>=1 and a[l]!=(a[i]+a[j]-a[l])){
								mp[a[i]+a[j]-a[l]]--;
								mp[a[l]]--;
								ans++;
								v.pb(a[l]);
								v.pb(a[i]+a[j]-a[l]);
//								cout<<"KI"<<endl;
							}
							if(a[l]==(a[i]+a[j]-a[l]) and mp[a[l]]>=2){
								v.pb(a[l]);
								v.pb(a[l]);
								mp[a[l]]-=2;
							}
						}
					}
//					cout<<ans<<endl;
					if(ans==((n/2)-1)){
						sort(v.begin(),v.end());
						for(int l=0;l<v.size();l++){
							cout<<v[l]<<" ";
						}
						cout<<endl;
						return 0;
					}
				}
			}
		}
	}
	
}
/*


																																						                               ###########################                     ##########################                                                                                  ################################
#####################################                     ####################					##############################################                                       ###############################                 ###############################                                                                              ##################################
#####################################                     ####################			    ##################################################                                      #################################               #################################                                                                            ####################################
#####################################                     ####################			######################################################                                     ###################################             ###################################                                                                          ######################################
#####################################                     ####################		 #########################################################    							      ############                #########           ########                 ############                                                                        ########################################
#####################################                     ####################		 ###############                                                                             ############                  #########         ########                   ############                                                                      ############                  ############
#####################################                     ####################		 ###############                                                                            ############                    #########       ########                     ############                                                                    ############                    ############
#################										  ####################		 ###############                                                                           ############                      #########     ########                       ############                                                                  ############                      ############
#################										  ####################		 ###############                                                                          ############                        ####################                         ############                                                                ############                        ############
#################															  		 ###############  		     	                                                         ############                           #################                           ############                                                              ############                          ############
#################									      ####################		 ###############                                                 		     	        ############                              ##############                             ############                                                            ############                            ############
#################									      ####################		 ###############                         		                                       ############                                ############                               ############                                                          ############                              ############
#################									      ####################		 ###############  		     	                                                      ############                                  ##########                                 ############                                                        ############                                ############
#####################################					  ####################		 ###############  		     	                                                     ############                                     ######                                    ############                                                      ############                                  ############
#####################################					  ####################		 ###############                                            		     	        ############                                       ####                                      ############                                                    ############################################################
#####################################					  ####################		 ###############                    ######################  		     	       ############                                                                                   ############                                                  ##############################################################
#####################################					  ####################		 ###############                    ######################  		     	      ############                                                                                     ############                                                ################################################################
#####################################					  ####################		 ###############                              ############  		     	     ############                                                                                       ############                                              ############                                          ############
#####################################					  ####################		 ###############                              ############  		     	    ############                                                                                         ############                                            ############                                            ############
				#####################					  ####################		 ###############                              ############   		     	   ############                                                                                           ############                                          ############                                              ############
				#####################					  ####################		 ###############                              ############  		     	  ############                                                                                             ############                                        ############                                                ############
				#####################					  ####################		 ###############                              ############					 ############                                                                                               ############                                      ############                                                  ############
				#####################					  ####################		 ###############                              ############  		        ############                                                                                                 ############                                    ############                                                    ############
				#####################					  ####################		 ###############                              ############  		       ############                                                                                                   ############                                  ############                                                      ############
				#####################					  ####################		 ###############                              ############  		      ############                                                                                                     ############                                ############                                                        ############
#####################################					  ####################		  ########################################################  		     ############                                                                                                       ############                              ############                                                          ############
#####################################					  ####################		   #######################################################  		    ############                                                                                                         ############                            ############                                                            ############
#####################################					  ####################		    #####################################################  		      ############                                                                                                            ############                          ############                                                              ############
#####################################					  ####################		       #################################################  		     ############				                                                                                               ############                        ############                                                                ############
*/

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int j=0;j<v.size();j++){
      |                 ~^~~~~~~~~
tabletennis.cpp:84:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |       for(int l=0;l<v.size();l++){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 646 ms 576 KB Output is correct
3 Correct 682 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 2900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3047 ms 20156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 545 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 286 ms 340 KB Output is correct
5 Correct 4 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 3051 ms 596 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 3060 ms 21652 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Execution timed out 3038 ms 21660 KB Time limit exceeded
3 Halted 0 ms 0 KB -