Submission #346833

#TimeUsernameProblemLanguageResultExecution timeMemory
346833arnold518Table Tennis (info1cup20_tabletennis)C++14
100 / 100
1483 ms16496 KiB
#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+400; const int MAXK = 400; const int MOD = 3000000+1; int N, K, A[MAXN+10]; int B[MOD+10]; int main() { scanf("%d%d", &N, &K); for(int i=1; i<=N+K; i++) scanf("%d", &A[i]); int tt=-1; 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++) { B[(A[i]+A[j])%MOD]+=2; if(B[(A[i]+A[j])%MOD]>=N) { tt=(A[i]+A[j])%MOD; break; } } if(tt!=-1) break; } vector<int> 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++) { if((A[i]+A[j])%MOD==tt) { V.push_back(A[i]); V.push_back(A[j]); } if(V.size()>=N) break; } if(V.size()>=N) break; } sort(V.begin(), V.end()); for(auto it : V) printf("%d ", it); printf("\n"); }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:47:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |    if(V.size()>=N) break;
      |       ~~~~~~~~^~~
tabletennis.cpp:49:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |   if(V.size()>=N) break;
      |      ~~~~~~~~^~~
tabletennis.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d%d", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~
tabletennis.cpp:18:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  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...