Submission #1023929

#TimeUsernameProblemLanguageResultExecution timeMemory
1023929AndreyThe Big Prize (IOI17_prize)C++14
20 / 100
58 ms424 KiB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;

int ans = -1;

void calc(int l, int r) {
	if(l > r) {
		return;
	}
	int m = (l+r)/2;
	vector<int> haha = ask(m);
	if(haha[0]+haha[1] == 0) {
		ans = m;
		return;
	}
	if(l == r) {
		return;
	}
	if(haha[0] > 0 && ans == -1) {
		calc(l,m-1);
	}
	if(haha[1] > 0 && ans == -1) {
		calc(m+1,r);
	}
}

int find_best(int n) {
	calc(0,n-1);
	if(ans == -1) {
		return 1/0;
	}
	return ans;
}

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:31:11: warning: division by zero [-Wdiv-by-zero]
   31 |   return 1/0;
      |          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...