답안 #101914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101914 2019-03-21T03:02:32 Z tim25871014 커다란 상품 (IOI17_prize) C++17
20 / 100
64 ms 396 KB
#include "prize.h"
using namespace std;

int find_best(int n){

    int loli=0;
    for(int i=0;i<475;i++){
        vector<int> ans=ask(i);
        loli=max(loli,ans[0]+ans[1]);
    }

    int l=0;
    while(ask(l)[1]!=0){
        int ub=n+1,lb=l;
        vector<int> ans;
        while(ub-lb>1){
            int mid=ub+lb>>1;
            while(ans=ask(mid),ans[0]+ans[1]!=loli){
                if(ans[0]+ans[1]==0) return mid;
                mid--;
            }
            if(ans[0]) ub=mid;
            else lb=mid;
        }
        ans=ask(lb);
        if(ans[0]+ans[1]==0) return lb;
        else l=lb+1;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:17:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid=ub+lb>>1;
                     ~~^~~
prize.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 7 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 4 ms 312 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 308 KB Output is correct
10 Correct 7 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 7 ms 308 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 8 ms 396 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Incorrect 64 ms 256 KB Incorrect
12 Halted 0 ms 0 KB -