제출 #407366

#제출 시각아이디문제언어결과실행 시간메모리
407366peuch커다란 상품 (IOI17_prize)C++17
0 / 100
9 ms6164 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; int find_best(int n) { srand(time(0)); vector<vector<int> > a(n); int maxi = 0; vector<int> ord; for(int i = 0; i < n; i++) ord.push_back(i); random_shuffle(ord.begin(), ord.end()); for(int i = 0; i < ord.size(); i++){ if(a[i].empty()) a[i] = ask(ord[i]); if(a[i][0] == 0 && a[i][1] == 0) return ord[i]; if(a[i][0] + a[i][1] > maxi) maxi = a[i][0] + a[i][1]; if(a[i][0] + a[i][1] == maxi){ int ini = i, fim = n - 1; bool flag = false; while(ini != fim){ int mid = (ini + fim) >> 1; if(ini == fim - 1) mid = fim; if(a[mid].empty()) a[mid] = ask(ord[mid]); if(a[mid][0] == 0 && a[mid][1] == 0) return ord[mid]; if(a[mid][0] + a[mid][1] > maxi){ maxi = a[mid][0] + a[mid][1]; flag = true; break; } if(a[mid][0] != a[i][0] || a[mid][1] != a[i][1]) fim = mid - 1; else ini = mid; } if(!flag) i = ini; } } return ord[n - 1]; }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i = 0; i < ord.size(); i++){
      |                 ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...