# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293175 | kshitij_sodani | 커다란 상품 (IOI17_prize) | C++14 | 105 ms | 5384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
#include "prize.h"
vector<int> pre[200001];
vector<int> ask2(int i){
if(pre[i].size()>0){
return pre[i];
}
pre[i]=ask(i);
return pre[i];
}
int find_best(int n) {
if(n<500){
for(int i = 0; i < n; i++) {
vector<int> res = ask2(i);
if(res[0] + res[1] == 0)
return i;
}
}
pair<int,int> ma={-1,-1};
for(int i=0;i<500;i++){
vector<int> res=ask2(i);
if(res[0]+res[1]==0){
return i;
}
if(res[0]+res[1]>=ma.a){
ma={res[0]+res[1],i};
}
}
int ind=ma.b;
/*ask2(n-1);
if(pre[n-1][0]+pre[n-1][1]==0){
return n-1;
}*/
while(ind<n){
vector<int> res=ask2(ind);
if(res[0]+res[1]==0){
return ind;
}
if(res[0]+res[1]<ma.a){
ind+=1;
continue;
}
/*if(res[0]==pre[n-1][0]){
break;
}*/
int low=ind+1;
int high=n-1;
while(low<high-1){
int mid=(low+high)/2;
vector<int> res2=ask2(mid);
if(res2[0]+res2[1]<ma.a){
high=mid;
}
else{
if(res2[0]==res[0]){
low=mid;
}
else{
high=mid;
}
}
}
int ind2=ind;
for(int i=low;i<=high;i++){
vector<int> res2=ask2(i);
if(res2[0]+res2[1]<ma.a){
ind=i;
break;
}
else{
if(res2[0]==res[0]){
continue;
}
else{
ind=i;
break;
}
}
}
if(pre[ind][0]+pre[ind][1]==0){
return ind;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |