Submission #346803

#TimeUsernameProblemLanguageResultExecution timeMemory
346803arnold518Table Tennis (info1cup20_tabletennis)C++14
72 / 100
3080 ms6996 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("avx, avx2, fma") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 15e4; const int MAXK = 400; int N, K, A[MAXN+10]; int main() { scanf("%d%d", &N, &K); for(int i=1; i<=N+K; i++) scanf("%d", &A[i]); vector<pii> V; for(int i=1; i<=N+K; i++) { int t=N+K-i+1; for(int j=max(i+1, t-K); j<=min(N+K, t+K); j++) { V.push_back({A[i], A[j]}); } } sort(V.begin(), V.end(), [&](const pii &p, const pii &q) { return p.first+p.second<q.first+q.second; }); for(int i=0; i<V.size();) { int j; for(j=i; j<V.size() && V[i].first+V[i].second==V[j].first+V[j].second; j++); if(j-i>=N/2) { vector<int> VV; for(int k=i; k<i+N/2; k++) { VV.push_back(V[k].first); VV.push_back(V[k].second); } sort(VV.begin(), VV.end()); for(auto it : VV) printf("%d ", it); printf("\n"); return 0; } i=j; } }

Compilation message (stderr)

tabletennis.cpp:4:39: warning: bad option '-favx' to pragma 'optimize' [-Wpragmas]
    4 | #pragma GCC optimize ("avx, avx2, fma")
      |                                       ^
tabletennis.cpp:4:39: warning: bad option '-f avx2' to pragma 'optimize' [-Wpragmas]
tabletennis.cpp:4:39: warning: bad option '-f fma' to pragma 'optimize' [-Wpragmas]
tabletennis.cpp:18:10: warning: bad option '-favx' to attribute 'optimize' [-Wattributes]
   18 | int main()
      |          ^
tabletennis.cpp:18:10: warning: bad option '-f avx2' to attribute 'optimize' [-Wattributes]
tabletennis.cpp:18:10: warning: bad option '-f fma' to attribute 'optimize' [-Wattributes]
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:33:57: warning: bad option '-favx' to attribute 'optimize' [-Wattributes]
   33 |  sort(V.begin(), V.end(), [&](const pii &p, const pii &q)
      |                                                         ^
tabletennis.cpp:33:57: warning: bad option '-f avx2' to attribute 'optimize' [-Wattributes]
tabletennis.cpp:33:57: warning: bad option '-f fma' to attribute 'optimize' [-Wattributes]
tabletennis.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=0; i<V.size();)
      |               ~^~~~~~~~~
tabletennis.cpp:41:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(j=i; j<V.size() && V[i].first+V[i].second==V[j].first+V[j].second; j++);
      |            ~^~~~~~~~~
tabletennis.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%d%d", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~
tabletennis.cpp:21:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  for(int i=1; i<=N+K; i++) scanf("%d", &A[i]);
      |                            ~~~~~^~~~~~~~~~~~~
#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...