Submission #668358

#TimeUsernameProblemLanguageResultExecution timeMemory
668358ar_paixaos19Table Tennis (info1cup20_tabletennis)C++14
72 / 100
3063 ms3556 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; const int MAXN = 150010; const int MAXK = 410; int v[MAXN + MAXK]; bool mark[MAXN + MAXK]; vector<pair<int, int>> resp(MAXN + MAXK); bool busca(int i, int j, int n){ resp.clear(); resp.pb(mp(i, j)); //printf("estou testando o meio %d %d\n", i, j); int s = v[i] + v[j]; int q = j + 1; int qtd = 1; for(int p = i - 1; p >= 1; p--){ while(v[p] + v[q] < s && q <= 2 * n){ q++; } if(v[p] + v[q] == s){ //printf("v[%d] + v[%d] funcionou\n", p, q); resp.pb(mp(p, q)); qtd++; q++; } if(qtd == n){ //printf("acabei o prob com meio %d %d\n", i, j); return true; } } return false; } int main(){ int N, k; scanf("%d %d", &N, &k); for(int i = 1; i <= N + k; i++){ scanf("%d", &v[i]); } int n = N / 2; bool achou = false; for(int i = n; (i <= n + k) && !achou; i++){ for(int j = i + 1; j <= n + k + 1; j++){ if(busca(i, j, n)){ achou = true; //printf("achou %d %d\n", i, j); goto NEXT; } resp.clear(); } } NEXT:; sort(resp.begin(), resp.end()); if(resp.size() < n){ printf("penis\n"); return 0; } for(int i = 0; i < n; i++){ printf("%d ", v[resp[i].first]); } for(int i = n - 1; i >= 0; i--){ printf("%d ", v[resp[i].second]); } printf("\n"); return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:62:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |     if(resp.size() < n){
      |        ~~~~~~~~~~~~^~~
tabletennis.cpp:39:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     int N, k; scanf("%d %d", &N, &k);
      |               ~~~~~^~~~~~~~~~~~~~~~~
tabletennis.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         scanf("%d", &v[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...