제출 #73388

#제출 시각아이디문제언어결과실행 시간메모리
73388hamzqq9커다란 상품 (IOI17_prize)C++14
0 / 100
3 ms308 KiB
#include "prize.h" #include<bits/stdc++.h> #define ii pair<int,int> #define st first #define nd second #define pb push_back using namespace std; set<int> s; int bg[200005][2]; int find_best(int n) { queue<ii> q; q.push({0,n-1}); while(!q.empty()) { ii query=q.front(); q.pop(); if(query.st>query.nd) continue ; vector<int> res; int mid=(query.st+query.nd)/2; cerr<<mid<<endl; res=ask(mid); if(res[0]==0 && res[1]==0) return mid; bg[mid][0]=res[0]; bg[mid][1]=res[1]; auto rnx=s.lower_bound(mid); auto lnx=s.lower_bound(mid); if(res[1]) { if(rnx==s.end() || bg[mid][1]>bg[*rnx][1] || bg[*rnx][0]>bg[mid][0]) q.push({mid+1,query.nd}); } if(res[0]) { if(lnx==s.begin() || bg[mid][1]<bg[*prev(lnx)][1] || bg[*prev(lnx)][0]<bg[mid][0]) q.push({query.st,mid-1}); } s.insert(mid); } assert(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...