Submission #101922

# Submission time Handle Problem Language Result Execution time Memory
101922 2019-03-21T03:34:49 Z tim25871014 The Big Prize (IOI17_prize) C++17
20 / 100
73 ms 396 KB
#include "prize.h"
using namespace std;

int find_best(int n){

    int loli=0;
    for(int i=0;i<500;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;
        int mid=1;
        while(ub-lb>1 && mid){
            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:18:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             mid=ub+lb>>1;
                 ~~^~~
prize.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 9 ms 256 KB Output is correct
3 Correct 7 ms 396 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 5 ms 308 KB Output is correct
5 Correct 5 ms 396 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 6 ms 304 KB Output is correct
11 Incorrect 73 ms 384 KB Incorrect
12 Halted 0 ms 0 KB -