제출 #136137

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

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

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