Submission #295917

# Submission time Handle Problem Language Result Execution time Memory
295917 2020-09-10T06:05:58 Z Aldas25 The Big Prize (IOI17_prize) C++14
90 / 100
105 ms 5628 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
mt19937 rng (chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 200100;

bool ch[MAXN];
vi got[MAXN];

vi get (int id) {
    if(!ch[id]) {
        ch[id] = true;
        got[id] = ask(id);
    }
    return got[id];
}


int brute_find (int n){
    FOR(i, 0, n-1) {
        vi a = get(i);
        if (a[0] + a[1] == 0) return i;
    }
    return 0;
}

int find_best(int n) {
    if (n <= 5000) return brute_find(n);
    int bg = 0; /// bg = 0
    int m = 1000; /// m = 1000
    FOR(i, 0, m-1) {
        vi a = get(i);
        if (a[0] + a[1] == 0) return i;
        bg = max(bg, a[0]+a[1]);
    }

    FOR(i, 0, n-1) {
        vi a = get(i);
        if (a[0] + a[1] == 0) return i;
        if (a[0] + a[1] == bg) {
            int le = i, ri = n-1;
            while (le < ri) {
                int mid = (le+ri+1)/2;
                vi a2 = get(mid);
                while (a2[0] + a2[1] != bg) {
                    if (a2[0] + a2[1] == 0) return mid;
                    mid--;
                    ri = mid;
                    a2 = get(mid);
                }
                if (a2[0] != a[0]) ri = mid-1;
                else le = mid;

            }
            i = le;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 5120 KB Output is correct
2 Correct 16 ms 5112 KB Output is correct
3 Correct 14 ms 5112 KB Output is correct
4 Correct 14 ms 5112 KB Output is correct
5 Correct 17 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 16 ms 5112 KB Output is correct
8 Correct 12 ms 5112 KB Output is correct
9 Correct 15 ms 5112 KB Output is correct
10 Correct 16 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 5256 KB Output is correct
2 Correct 12 ms 5112 KB Output is correct
3 Correct 16 ms 5112 KB Output is correct
4 Correct 12 ms 5112 KB Output is correct
5 Correct 12 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 11 ms 4992 KB Output is correct
8 Correct 17 ms 5084 KB Output is correct
9 Correct 9 ms 5088 KB Output is correct
10 Correct 13 ms 5120 KB Output is correct
11 Correct 15 ms 5364 KB Output is correct
12 Correct 11 ms 5248 KB Output is correct
13 Correct 19 ms 5240 KB Output is correct
14 Correct 16 ms 5112 KB Output is correct
15 Correct 29 ms 5112 KB Output is correct
16 Partially correct 79 ms 5368 KB Partially correct - number of queries: 7492
17 Correct 8 ms 4992 KB Output is correct
18 Partially correct 75 ms 5496 KB Partially correct - number of queries: 8594
19 Correct 8 ms 5068 KB Output is correct
20 Correct 28 ms 5112 KB Output is correct
21 Correct 40 ms 5240 KB Output is correct
22 Correct 15 ms 5120 KB Output is correct
23 Correct 14 ms 5116 KB Output is correct
24 Correct 10 ms 5136 KB Output is correct
25 Partially correct 54 ms 5392 KB Partially correct - number of queries: 5273
26 Partially correct 53 ms 5368 KB Partially correct - number of queries: 5221
27 Correct 12 ms 5112 KB Output is correct
28 Partially correct 47 ms 5496 KB Partially correct - number of queries: 8140
29 Partially correct 67 ms 5368 KB Partially correct - number of queries: 6402
30 Partially correct 83 ms 5496 KB Partially correct - number of queries: 8527
31 Correct 8 ms 4992 KB Output is correct
32 Correct 16 ms 5240 KB Output is correct
33 Correct 4 ms 4992 KB Output is correct
34 Correct 33 ms 5240 KB Output is correct
35 Correct 14 ms 5272 KB Output is correct
36 Correct 31 ms 5240 KB Output is correct
37 Correct 15 ms 5200 KB Output is correct
38 Correct 10 ms 5112 KB Output is correct
39 Correct 32 ms 5392 KB Output is correct
40 Partially correct 44 ms 5604 KB Partially correct - number of queries: 7422
41 Partially correct 59 ms 5368 KB Partially correct - number of queries: 5552
42 Partially correct 54 ms 5344 KB Partially correct - number of queries: 5552
43 Partially correct 51 ms 5292 KB Partially correct - number of queries: 5086
44 Correct 38 ms 5368 KB Output is correct
45 Correct 46 ms 5224 KB Output is correct
46 Correct 6 ms 5128 KB Output is correct
47 Correct 35 ms 5464 KB Output is correct
48 Partially correct 38 ms 5444 KB Partially correct - number of queries: 6623
49 Correct 23 ms 5120 KB Output is correct
50 Partially correct 101 ms 5628 KB Partially correct - number of queries: 8602
51 Correct 54 ms 5240 KB Output is correct
52 Correct 17 ms 5112 KB Output is correct
53 Correct 16 ms 5112 KB Output is correct
54 Correct 66 ms 5240 KB Output is correct
55 Correct 9 ms 4992 KB Output is correct
56 Partially correct 70 ms 5412 KB Partially correct - number of queries: 8581
57 Partially correct 66 ms 5368 KB Partially correct - number of queries: 6530
58 Partially correct 66 ms 5368 KB Partially correct - number of queries: 6620
59 Partially correct 70 ms 5368 KB Partially correct - number of queries: 5547
60 Partially correct 56 ms 5368 KB Partially correct - number of queries: 5238
61 Correct 14 ms 5112 KB Output is correct
62 Correct 13 ms 5112 KB Output is correct
63 Correct 15 ms 5212 KB Output is correct
64 Correct 14 ms 5112 KB Output is correct
65 Correct 13 ms 5112 KB Output is correct
66 Correct 19 ms 5112 KB Output is correct
67 Correct 9 ms 5176 KB Output is correct
68 Correct 8 ms 4992 KB Output is correct
69 Correct 16 ms 5120 KB Output is correct
70 Correct 17 ms 5112 KB Output is correct
71 Partially correct 85 ms 5496 KB Partially correct - number of queries: 8750
72 Correct 23 ms 5240 KB Output is correct
73 Partially correct 84 ms 5496 KB Partially correct - number of queries: 8635
74 Partially correct 93 ms 5496 KB Partially correct - number of queries: 8687
75 Correct 18 ms 5112 KB Output is correct
76 Partially correct 93 ms 5448 KB Partially correct - number of queries: 7624
77 Partially correct 83 ms 5496 KB Partially correct - number of queries: 8623
78 Correct 19 ms 5240 KB Output is correct
79 Correct 53 ms 5428 KB Output is correct
80 Partially correct 102 ms 5496 KB Partially correct - number of queries: 8617
81 Partially correct 81 ms 5496 KB Partially correct - number of queries: 8634
82 Partially correct 105 ms 5496 KB Partially correct - number of queries: 8534
83 Correct 14 ms 5112 KB Output is correct
84 Partially correct 74 ms 5368 KB Partially correct - number of queries: 7202
85 Partially correct 59 ms 5504 KB Partially correct - number of queries: 8627
86 Correct 16 ms 5112 KB Output is correct
87 Correct 16 ms 5112 KB Output is correct
88 Correct 18 ms 5112 KB Output is correct
89 Correct 12 ms 5112 KB Output is correct
90 Correct 13 ms 5152 KB Output is correct
91 Correct 13 ms 5112 KB Output is correct
92 Correct 16 ms 5120 KB Output is correct
93 Correct 17 ms 5240 KB Output is correct
94 Correct 20 ms 5240 KB Output is correct
95 Correct 21 ms 5240 KB Output is correct
96 Correct 11 ms 5232 KB Output is correct
97 Correct 12 ms 5112 KB Output is correct