Submission #90000

# Submission time Handle Problem Language Result Execution time Memory
90000 2018-12-19T15:45:18 Z nikolapesic2802 The Big Prize (IOI17_prize) C++14
20 / 100
45 ms 1496 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;

int doit(int l,int r)
{
    int m=(l+r)>>1;
    vector<int> tr=ask(m);
    if(tr[0]+tr[1]==0)
        return m;
    if(l==r)
        return -1;
    if(tr[0]>tr[1])
    {
        int tr=doit(l,m-1);
        if(tr!=-1)
            return tr;
        return doit(m+1,r);
    }
    else
    {
        int tr=doit(m+1,r);
        if(tr!=-1)
            return tr;
        return doit(l,m-1);
    }
}
int find_best(int n) {
    return doit(0,n-1);
    int l=0,r=n-1;
    while(true)
    {
        int m=(l+r)>>1;
        vector<int> tr=ask(m);
        if(tr[0]==1)
        {
            r=m-1;
        }
        else
        {
            if(tr[1]==1)
            {
                l=m+1;
            }
            else
            {
                return m;
            }
        }
    }
	/*for(int i = 0; i < n; i++) {
		std::vector<int> res = ask(i);
		if(res[0] + res[1] == 0)
			return i;
	}
	return 0;*/
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 424 KB Output is correct
2 Correct 2 ms 424 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 548 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 548 KB Output is correct
10 Correct 2 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Incorrect 45 ms 1496 KB Incorrect
12 Halted 0 ms 0 KB -