Submission #890289

#TimeUsernameProblemLanguageResultExecution timeMemory
890289activedeltorreTable Tennis (info1cup20_tabletennis)C++14
100 / 100
127 ms11716 KiB
#include <algorithm> #include <iostream> #include <vector> #include <map> using namespace std; map<int,int>fre; int v[155005],m,k,n; vector<int>vec; int calc(int i ,int j) { int useless,st,dr; if(fre[v[i]+v[j]]==1) { return 0; } fre[v[i]+v[j]]=1; useless=i-1+m-j; st=i; dr=j; int grupe=0; while(useless<=k) { if(dr<=st) { break; } if(v[st]+v[dr]==v[i]+v[j]) { vec.push_back(v[st]); vec.push_back(v[dr]); st++; dr--; grupe+=2; } else if(v[st]+v[dr]<v[i]+v[j]) { st++; useless++; } else { dr--; useless++; } if(grupe==n) { break; } } if(grupe>=n) { sort(vec.begin(),vec.end()); for(i=0;i<n;i++) { cout<<vec[i]<<" "; } return 1; } vec.clear(); return 0; } int main() { int i,j,l,z; cin>>n>>k; m=n+k; for(i=1;i<=m;i++) { cin>>v[i]; } int imp=0; for(i=1;i<=k+1;i++) { for(j=0;j<=k;j++) { z=m-j; if(z>i && imp==0) { if(calc(i,z)==1) { imp=1; } } } } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:65:13: warning: unused variable 'l' [-Wunused-variable]
   65 |     int i,j,l,z;
      |             ^
#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...