제출 #668366

#제출 시각아이디문제언어결과실행 시간메모리
668366ar_paixaos19Table Tennis (info1cup20_tabletennis)C++14
87 / 100
3058 ms4044 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, int k){ 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 + k){ 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; int minmid = max(1,n-3), maxmid = min(N+k,n+k+3); for(int i = minmid; i <= maxmid && !achou; i++){ for(int j = i+1; j <= maxmid; j++){ if(busca(i, j, n, k)){ achou = true; //printf("achou %d %d\n", i, j); break; } } } sort(resp.begin(), resp.end()); if(resp.size() < n){ printf("%dpenis%d\n", n,resp.size()); 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; }

컴파일 시 표준 에러 (stderr) 메시지

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:60: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]
   60 |     if(resp.size() < n){
      |        ~~~~~~~~~~~~^~~
tabletennis.cpp:61:25: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   61 |         printf("%dpenis%d\n", n,resp.size());
      |                        ~^       ~~~~~~~~~~~
      |                         |                |
      |                         int              std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
      |                        %ld
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...