Submission #722579

# Submission time Handle Problem Language Result Execution time Memory
722579 2023-04-12T11:31:27 Z tvladm2009 The Big Prize (IOI17_prize) C++17
100 / 100
69 ms 11476 KB
#include <bits/stdc++.h>
#include "prize.h"

using namespace std;

typedef long long ll;

const int N_MAX = 200000;

vector <int> L, R;

void discover(int mid) {
    if (L[mid] == -1) {
        vector <int> resp = ask(mid);
        L[mid] = resp[0];
        R[mid] = resp[1];
    }
}

map <int, int> mp[N_MAX + 2];

int solve(int l, int r) {
    int mid = (l + r) / 2;
    discover(mid);
    int cntLess = L[mid] + R[mid];
    if (cntLess == 0) {
        return mid;
    }
    mp[cntLess][mid] = L[mid];
    auto it = mp[cntLess].find(mid);
    if (l < mid && (it == mp[cntLess].begin() || L[mid] - prev(it)->second > 0)) {
        int sl = solve(l, mid - 1);
        if (sl != -1) {
            return sl;
        }
    }
    if (mid < r && (next(it) == mp[cntLess].end() || next(it)->second - L[mid] > 0)) {
        int sr = solve(mid + 1, r);
        if (sr != -1) {
            return sr;
        }
    }
    return -1;
}

int find_best(int N) {
    L = vector <int> (N, -1);
    R = vector <int> (N, -1);
    return solve(0, N - 1);
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11228 KB Output is correct
2 Correct 7 ms 11216 KB Output is correct
3 Correct 7 ms 11212 KB Output is correct
4 Correct 6 ms 11216 KB Output is correct
5 Correct 8 ms 11168 KB Output is correct
6 Correct 8 ms 11212 KB Output is correct
7 Correct 8 ms 11204 KB Output is correct
8 Correct 6 ms 11228 KB Output is correct
9 Correct 8 ms 11228 KB Output is correct
10 Correct 6 ms 11152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11216 KB Output is correct
2 Correct 6 ms 11220 KB Output is correct
3 Correct 7 ms 11204 KB Output is correct
4 Correct 6 ms 11200 KB Output is correct
5 Correct 7 ms 11220 KB Output is correct
6 Correct 7 ms 11224 KB Output is correct
7 Correct 8 ms 11216 KB Output is correct
8 Correct 6 ms 11220 KB Output is correct
9 Correct 6 ms 11224 KB Output is correct
10 Correct 6 ms 11216 KB Output is correct
11 Correct 7 ms 11204 KB Output is correct
12 Correct 6 ms 11220 KB Output is correct
13 Correct 11 ms 11268 KB Output is correct
14 Correct 8 ms 9800 KB Output is correct
15 Correct 12 ms 11204 KB Output is correct
16 Correct 41 ms 11420 KB Output is correct
17 Correct 6 ms 11200 KB Output is correct
18 Correct 50 ms 11464 KB Output is correct
19 Correct 7 ms 11204 KB Output is correct
20 Correct 14 ms 10456 KB Output is correct
21 Correct 18 ms 11212 KB Output is correct
22 Correct 9 ms 11220 KB Output is correct
23 Correct 6 ms 11220 KB Output is correct
24 Correct 7 ms 11216 KB Output is correct
25 Correct 27 ms 11332 KB Output is correct
26 Correct 26 ms 11348 KB Output is correct
27 Correct 8 ms 11204 KB Output is correct
28 Correct 50 ms 11428 KB Output is correct
29 Correct 23 ms 11360 KB Output is correct
30 Correct 52 ms 11464 KB Output is correct
31 Correct 6 ms 11216 KB Output is correct
32 Correct 9 ms 11212 KB Output is correct
33 Correct 5 ms 9680 KB Output is correct
34 Correct 19 ms 11296 KB Output is correct
35 Correct 9 ms 11216 KB Output is correct
36 Correct 18 ms 11212 KB Output is correct
37 Correct 8 ms 11216 KB Output is correct
38 Correct 7 ms 11220 KB Output is correct
39 Correct 21 ms 11340 KB Output is correct
40 Correct 58 ms 11432 KB Output is correct
41 Correct 43 ms 11344 KB Output is correct
42 Correct 31 ms 11332 KB Output is correct
43 Correct 29 ms 11348 KB Output is correct
44 Correct 21 ms 11308 KB Output is correct
45 Correct 14 ms 11212 KB Output is correct
46 Correct 7 ms 11216 KB Output is correct
47 Correct 15 ms 11332 KB Output is correct
48 Correct 36 ms 11380 KB Output is correct
49 Correct 11 ms 11216 KB Output is correct
50 Correct 49 ms 11456 KB Output is correct
51 Correct 24 ms 11324 KB Output is correct
52 Correct 7 ms 11200 KB Output is correct
53 Correct 8 ms 11204 KB Output is correct
54 Correct 29 ms 11280 KB Output is correct
55 Correct 7 ms 11204 KB Output is correct
56 Correct 60 ms 11472 KB Output is correct
57 Correct 31 ms 11340 KB Output is correct
58 Correct 46 ms 11388 KB Output is correct
59 Correct 34 ms 11292 KB Output is correct
60 Correct 34 ms 11332 KB Output is correct
61 Correct 7 ms 11208 KB Output is correct
62 Correct 6 ms 11204 KB Output is correct
63 Correct 8 ms 11216 KB Output is correct
64 Correct 8 ms 11224 KB Output is correct
65 Correct 7 ms 11220 KB Output is correct
66 Correct 7 ms 11220 KB Output is correct
67 Correct 7 ms 11216 KB Output is correct
68 Correct 8 ms 11216 KB Output is correct
69 Correct 8 ms 11260 KB Output is correct
70 Correct 8 ms 11220 KB Output is correct
71 Correct 69 ms 11464 KB Output is correct
72 Correct 11 ms 11280 KB Output is correct
73 Correct 60 ms 11408 KB Output is correct
74 Correct 64 ms 11376 KB Output is correct
75 Correct 7 ms 11276 KB Output is correct
76 Correct 38 ms 11384 KB Output is correct
77 Correct 45 ms 11452 KB Output is correct
78 Correct 11 ms 11216 KB Output is correct
79 Correct 36 ms 11304 KB Output is correct
80 Correct 44 ms 11436 KB Output is correct
81 Correct 53 ms 11464 KB Output is correct
82 Correct 48 ms 11452 KB Output is correct
83 Correct 11 ms 11216 KB Output is correct
84 Correct 51 ms 11476 KB Output is correct
85 Correct 67 ms 11392 KB Output is correct
86 Correct 12 ms 11276 KB Output is correct
87 Correct 10 ms 11216 KB Output is correct
88 Correct 13 ms 11216 KB Output is correct
89 Correct 11 ms 11296 KB Output is correct
90 Correct 10 ms 11216 KB Output is correct
91 Correct 9 ms 11216 KB Output is correct
92 Correct 7 ms 11200 KB Output is correct
93 Correct 10 ms 11216 KB Output is correct
94 Correct 9 ms 11216 KB Output is correct
95 Correct 9 ms 11216 KB Output is correct
96 Correct 8 ms 11216 KB Output is correct
97 Correct 6 ms 11216 KB Output is correct