답안 #102067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102067 2019-03-22T01:50:25 Z daniel920712 커다란 상품 (IOI17_prize) C++14
20 / 100
3 ms 432 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "prize.h"

using namespace std;

int find_best(int n)
{
    vector < int > t;
    int i,l,r;
    t=ask(0);
    if(t[0]==0&&t[1]==0) return 0;
    t=ask(n-1);
    if(t[0]==0&&t[1]==0) return n-1;
    l=0;
    r=n;
    while((r-l)>1)
    {
        t=ask((l+r)/2);
        //printf("%d %d %d %d\n",l,r,t[0],t[1]);
        if(t[0]==0&&t[1]==0) return (l+r)/2;
        if(t[0]==1) r=(l+r)/2;
        else l=(l+r)/2;
    }
    t=ask(l);
    if(t[0]==0&&t[1]==0) return l;
    else return r;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:11:9: warning: unused variable 'i' [-Wunused-variable]
     int i,l,r;
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 312 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 304 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 304 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 432 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 304 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Incorrect 3 ms 308 KB Integer 200000 violates the range [0, 199999]
12 Halted 0 ms 0 KB -