Submission #1075851

# Submission time Handle Problem Language Result Execution time Memory
1075851 2024-08-26T09:31:02 Z mdn2002 The Big Prize (IOI17_prize) C++14
0 / 100
8 ms 596 KB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;

int find_best(int n) {
	int mx = 0, lim = 500;
	for (int i = 0; i < min(n, lim); i ++) {
        vector<int> a = ask(i);
        mx = max(mx, a[0] + a[1]);
        if (a[0] + a[1] == 0) return i;
	}

	for (int i = 0; i < n; i ++) {
        vector<int> a = ask(i);
        if (a[0] + a[1] == mx) {
            vector<int> c = ask(min(n - 1, i + 220));
            if (a[1] == c[1]) {
                i = min(n - 1, i + lim);
                continue;
            }
            for (int j = 220; j >= 1; j = (j + 1) / 2) {
                if (i + j >= n) continue;
                vector<int> b = ask(i + j);
                if (a[1] == b[1]) i += j;
                if (j == 1) break;
            }
        }
        else if (a[0] + a[1] == 0) return i;
	}
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 596 KB Output is correct
2 Incorrect 6 ms 344 KB Integer 200000 violates the range [0, 199999]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Incorrect 8 ms 436 KB Integer 200000 violates the range [0, 199999]
3 Halted 0 ms 0 KB -