제출 #415117

#제출 시각아이디문제언어결과실행 시간메모리
415117Bill_00커다란 상품 (IOI17_prize)C++14
90 / 100
125 ms1880 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int l[200005],r[200005],x[200005]; int find_best(int n){ // for(int i = 0; i < n; i++){ // std::vector<int> res = ask(i); // if(res[0] + res[1] == 0) // return i; // } for(int i=0;i<n;i++){ l[i]=r[i]=-1; } pair<int,int>k={0,-1}; for(int i=0;i<min(473,n);i++){ vector<int>res=ask(i); l[i]=res[0]; r[i]=res[1]; if(l[i]+r[i]==0) return i; k=max(k,{res[0]+res[1],i}); } int beg; for(int i=0;i<min(473,n);i++){ if(l[i]+r[i]==k.first){ beg=i; break; } } for(int i=beg;i<n;i++){ if(l[i]==-1){ vector<int>res=ask(i); l[i]=res[0]; r[i]=res[1]; } // cout << l[i] << ' ' << r[i] << ' ' << i << '\n'; if(l[i]+r[i]==0) return i; if(l[i]+r[i]==k.first){ int L=i,R=n-1; while(L<R){ int m=(1+L+R)>>1; if(l[m]==-1){ vector<int>res=ask(m); l[m]=res[0]; r[m]=res[1]; } if(l[m]+r[m]==0) return m; // cout << m << ' ' << l[m] << ' ' << r[m] << '\n'; if(r[m]==r[i]){ L=m; } else R=m-1; } i=L; } // cout << i << '\n'; } return 0; }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:48:17: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     if(r[m]==r[i]){
      |              ~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...