Submission #423862

#TimeUsernameProblemLanguageResultExecution timeMemory
423862kai824Table Tennis (info1cup20_tabletennis)C++17
0 / 100
3062 ms60752 KiB
#include<bits/stdc++.h> using namespace std; #define f first #define s second #define int long long typedef pair<int,int> pii; #define mp make_pair #define eb emplace_back int n,k; int arr[20]; int used=0; int cnt_1,cnt_k,s1,s2; bool ans=false; void brute(int i){ if(ans)return; if(i==n+k){ if(cnt_k<k || cnt_1<(n/2))return; if(s1==s2)ans=true; return; } if(cnt_k<k){ cnt_k++; used^=(1<<i); brute(i+1); //if(ans)cerr<<0; if(ans)return; used^=(1<<i); cnt_k--; } if(cnt_1<(n/2)){ cnt_1++;s1+=arr[i]; brute(i+1); //if(ans)cerr<<1; if(ans)return; cnt_1--;s1-=arr[i]; } s2+=arr[i];brute(i+1);s2-=arr[i]; //if(ans)cerr<<2; } int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(0); cin>>n>>k; for(int i=0;i<n+k;i++){ cin>>arr[i]; } brute(0); vector<int> v; for(int i=0;i<n+k;i++){ if(used&(1<<i)); else v.push_back(arr[i]); } for(int i=0;i<v.size();i++){ cout<<v[i]; if(i+1<v.size())cout<<' '; } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int32_t main()':
tabletennis.cpp:58:16: 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]
   58 |   for(int i=0;i<v.size();i++){
      |               ~^~~~~~~~~
tabletennis.cpp:60:11: 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]
   60 |     if(i+1<v.size())cout<<' ';
      |        ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...