제출 #136095

#제출 시각아이디문제언어결과실행 시간메모리
136095alexandra_udristoiu커다란 상품 (IOI17_prize)C++14
20 / 100
72 ms504 KiB
#include<iostream> #include<vector> #include<cmath> #include "prize.h" using namespace std; static int nr, x; void solve(int p, int u, int nrp, int nru){ if(p > u || nrp + nru == nr){ return; } vector<int> a; int mid, m; if(p == u){ a = ask(p); if(a[0] + a[1] == 0){ x = p; } return; } mid = (p + u) / 2; m = mid; while(m >= p){ a = ask(m); if(a[0] + a[1] == 0){ x = m; return; } if(a[0] + a[1] == nr){ break; } m--; } solve(p, m, nrp, a[1]); solve(mid + 1, u, a[0] + mid - m, nru); } int find_best(int n){ int r, i, p; vector<int> a; r = sqrt(n * 1.0); for(i = 0; i <= r; i++){ a = ask(i); if(a[0] == 0 && a[1] == 0){ return i; } if(nr <= a[1] + a[0]){ nr = a[1] + a[0]; p = i; } } a = ask(p); solve(p, n - 1, a[0], 0); return x; }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:50:12: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
     a = ask(p);
         ~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...