제출 #135879

#제출 시각아이디문제언어결과실행 시간메모리
135879alexandra_udristoiu커다란 상품 (IOI17_prize)C++14
90 / 100
90 ms528 KiB
#include<iostream> #include<vector> #include<cmath> #include "prize.h" using namespace std; static int lst[200005]; int find_best(int n){ int nr, p, st, dr, mid, r, i, x; vector<int> a; r = sqrt(n * 1.0); x = 0; for(i = 0; i <= r; i++){ a = ask(i); lst[ a[1] ] = max(lst[ a[1] ], i); if(a[0] == 0 && a[1] == 0){ return i; } if(x <= a[1] + a[0]){ x = a[1] + a[0]; p = i; nr = a[1]; } } while(nr > 0){ st = max(p, lst[nr]) + 1; dr = n; while(st <= dr){ mid = (st + dr) / 2; a = ask(mid); lst[ a[1] ] = max( lst[ a[1] ], mid); if(a[1] == nr){ st = mid + 1; } else{ dr = mid - 1; } } a = ask(st); if(a[1] == 0){ return st; } p = st; nr--; } }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
prize.cpp:8:13: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int nr, p, st, dr, mid, r, i, x;
             ^
prize.cpp:8:9: warning: 'nr' may be used uninitialized in this function [-Wmaybe-uninitialized]
     int nr, p, st, dr, mid, r, i, x;
         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...