Submission #1019323

# Submission time Handle Problem Language Result Execution time Memory
1019323 2024-07-10T17:25:56 Z overwatch9 The Big Prize (IOI17_prize) C++17
0 / 100
1000 ms 11352 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
// int N;
// vector <int> nums;
// vector <int> ask(int i) {
//     vector <int> ans(2, 0);
//     for (int j = 0; j < i; j++) {
//         if (nums[j] > nums[i])
//             ans[0]++;
//     }
//     for (int j = i+1; j < N; j++) {
//         if (nums[j] > nums[i])
//             ans[1]++;
//     }
//     return ans;
// }
 
int find_best(int n){
	vector <vector <int>> p(n, {-1, -1});
	int mx = 0, idx = 0;
	for (int i = 0; i < 500; i++) {
		p[i] = ask(i);
		if (p[i][0] + p[i][1] == 0)
			return i;
		if (mx < p[i][0] + p[i][1]) {
			mx = p[i][0] + p[i][1];
			idx = i;
		}
	}
	for (int i = idx; i < n; i++) {
		if (p[i][0] == -1)
			p[i] = ask(i);
		if (p[i][0] + p[i][1] == 0)
			return i;
		if (p[i][0] + p[i][1] < mx)
			continue;
		int lo = i, hi = n;
		while (lo < hi) {
			int mid = lo + (hi - lo) / 2;
			if (p[mid][0] == -1) {
				p[mid] = ask(mid);
			}
			vector <int> res = p[mid];
			if (res == p[i])
				lo = mid;
			else
				hi = mid - 1;
		}
		i = lo;
	}
	return 0;

}

// int main() {
//     cin >> N;
//     nums.resize(N+1);
//     for (int i = 0; i < N; i++)
//         cin >> nums[i];
//     find_best(N);
// }
# Verdict Execution time Memory Grader output
1 Execution timed out 3012 ms 11352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3060 ms 11352 KB Time limit exceeded
2 Halted 0 ms 0 KB -