Submission #689815

#TimeUsernameProblemLanguageResultExecution timeMemory
689815TomitaMateiTable Tennis (info1cup20_tabletennis)C++14
35 / 100
3087 ms468 KiB
#include <iostream> #include <algorithm> using namespace std; int n,k,i,j,i1,j2,t,dr,st,s,nr,v[16000],r[16000],ok; int main() { cin>>n>>k; for (i=1; i<=n+k; i++) cin>>v[i]; sort (v+1,v+n+k+1); for (st=1; st<=n; st++) for (dr=n+k; dr>=1; dr--) { i=st; j=dr; s=v[i]+v[j]; nr=1; r[1]=v[i]; r[n-nr+1]=v[j]; i++; j--; ok=0; if (nr*2==n) { for (i=1; i<=n; i++) cout<<r[i]<<" "; return 0; } while (i<j) { for (j2=j; j2>i; j2--) if (s==v[i]+v[j2]) { nr++; r[n-nr+1]=v[j2]; r[nr]=v[i]; ok=1; break; } if (nr*2==n) { for (i=1; i<=n; i++) cout<<r[i]<<" "; return 0; } if (ok==0) i++; else { ok=0; i++; j=j2-1; } } } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:9:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    9 |     for (i=1; i<=n+k; i++)
      |     ^~~
tabletennis.cpp:12:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   12 |         sort (v+1,v+n+k+1);
      |         ^~~~
#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...