Submission #379714

#TimeUsernameProblemLanguageResultExecution timeMemory
379714YJUTable Tennis (info1cup20_tabletennis)C++14
38 / 100
3089 ms11628 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; const ll N=15e4+400+1; ll u[N],n,k,vis[N]; vector<ll> lis; bool ck(ll m,ll flag){ multiset<ll> ms; vector<ll> ret; for(int i=0;i<n;i++)ms.insert(u[i]); while(!ms.empty()){ if(ret.size()==n-k)break; ll x=*ms.begin();ms.erase(ms.begin()); if(ms.find(m-x)!=ms.end()){ ret.push_back(x);ret.push_back(m-x); ms.erase(ms.find(m-x)); } } if(flag&&(ret.size()==n-k)){ sort(ret.begin(),ret.end()); for(int i=0;i<ret.size();i++) cout<<ret[i]<<" \n"[i==ret.size()-1]; return 0; }else{ return (ret.size()==n-k); } } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>k; n+=k; for(int i=0;i<n;i++)cin>>u[i]; for(int i=0;i<k;i++){ for(int j=n-1;j>=n-k-1&&j>i;j--){ if(i+n-1-j>k)break; lis.push_back(u[i]+u[j]); } } sort(lis.begin(),lis.end()); lis.erase(unique(lis.begin(),lis.end()),lis.end()); for(auto i:lis){ //cout<<i<<"\n"; ll tmp=ck(i,0); if(tmp){ ck(i,1); return 0; } //cout<<ck(i,0)<<"\n"; } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'bool ck(ll, ll)':
tabletennis.cpp:15:16: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   15 |   if(ret.size()==n-k)break;
      |      ~~~~~~~~~~^~~~~
tabletennis.cpp:22:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |  if(flag&&(ret.size()==n-k)){
      |            ~~~~~~~~~~^~~~~
tabletennis.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int i=0;i<ret.size();i++)
      |               ~^~~~~~~~~~~
tabletennis.cpp:25:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    cout<<ret[i]<<" \n"[i==ret.size()-1];
      |                        ~^~~~~~~~~~~~~~
tabletennis.cpp:28:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   28 |   return (ret.size()==n-k);
      |           ~~~~~~~~~~^~~~~
#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...