Submission #718291

#TimeUsernameProblemLanguageResultExecution timeMemory
718291MrM7mdTable Tennis (info1cup20_tabletennis)C++17
87 / 100
3049 ms3596 KiB
#include <bits/stdc++.h> using namespace std; // #define int long long #define endl '\n' #define F first #define S second #define pb push_back #define all(a) a.begin(),a.end() const int N=1e5; const int off=(1<<20); const int MOD = 1e9+7; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n,k; cin >> n >> k; int sz=n+k; int a[sz]; // map<int,bool>mp; for(int i=0;i<sz;i++){ cin >>a[i]; // mp[a[i]]=1; } // sort(a,a+sz); for(int i=0;i<=k;i++){ for(int j=0;j<=k-i;j++){ int ans=a[i]+a[sz-j-1]; int cur=i+j; vector<int>sml,big; int l=i,r=sz-j-1; while(l<=r){ if(l==r){ break; } if(a[l]+a[r]==ans){ sml.pb(a[l]); big.pb(a[r]); l++; r--; } else if(a[l]+a[r]>ans){ r--; } else{ l++; } } if(sml.size()+big.size()==n){ for(auto it:sml){ cout<<it<<' '; } for(int i=big.size()-1;i>=0;i--)cout<<big[i]<<' '; return 0; } // cout<<v.back()<<' '; } } // cout<<v.size()<<endl; } /* */

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:50:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |          if(sml.size()+big.size()==n){
      |             ~~~~~~~~~~~~~~~~~~~~~^~~
tabletennis.cpp:30:14: warning: unused variable 'cur' [-Wunused-variable]
   30 |          int cur=i+j;
      |              ^~~
#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...