Submission #975442

# Submission time Handle Problem Language Result Execution time Memory
975442 2024-05-05T07:51:05 Z pirhosig The Big Prize (IOI17_prize) C++17
20 / 100
49 ms 600 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;



int find_best(int n) {
	if (n < 5000) {
		for (int i = 0; i < n; ++i) {
			auto a = ask(i);
			if (a[0] + a[1] == 0) return i;
		}
	}

	int large = 0;
	for (int i = 0; i < 450; ++i) {
		auto a = ask(i);
		large = max(large, a[0] + a[1]);
	}

	int low = 0;
	for (int i = 1; i <= large; ++i) {
		int upp = n - 1;
		while (low < upp) {
			int mid = (low + upp) / 2;
			auto a = ask(mid);
			int tot = a[0] + a[1];
			if (tot == 0) return mid;
			if (tot == large) {
				if (a[0] < i) low = mid + 1;
				else upp = mid - 1;
			}
			else {
				int dvm = mid;
				while (tot < large) {
					dvm--;
					a = ask(dvm);
					tot = a[0] + a[1];
					if (tot == 0) return dvm;
				}
				if (a[0] + dvm - mid >= i) i += dvm - mid - 1;
				else low = mid + 1;
			}
		}
		auto a = ask(low);
		if (a[0] + a[1] == 0) return low;
		low++;
	}

	return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 3 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 5 ms 428 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 8 ms 436 KB Output is correct
16 Incorrect 49 ms 596 KB Incorrect
17 Halted 0 ms 0 KB -