Submission #1075842

#TimeUsernameProblemLanguageResultExecution timeMemory
1075842mdn2002The Big Prize (IOI17_prize)C++14
20 / 100
50 ms436 KiB
#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int find_best(int n) {
	int mx = 0, lim = 500, xx = 10;

	while (xx --) {
        int i = rnd() % n;
        vector<int> a = ask(i);
        mx = max(mx, a[0] + a[1]);
	}

	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 + lim));
            if (a[1] == c[1]) {
                i = min(n - 1, i + lim);
                continue;
            }
            for (int j = 500; 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 (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
   32 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...