답안 #471353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471353 2021-09-08T14:14:55 Z dxz05 커다란 상품 (IOI17_prize) C++14
90 / 100
115 ms 12556 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e5 + 3e2;
typedef long long ll;

//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

vector<int> asked_values[MAXN];

int cnt = 0;
vector<int> ASK(int i){
    vector<int> res;
    if (asked_values[i].empty()){
        cnt++;
        assert(cnt <= 10000);
        res = ask(i);
        asked_values[i] = res;
        //cout << i << ' ' << res.front() << ' ' << res.back() << endl;
    } else res = asked_values[i];
    return res;
}

int find_best(int n) {
    vector<int> res;

    int mx = 0;
    int pos = 0;
    while (pos < 500){
        ASK(pos);
        res = ASK(pos);
        if (res[0] + res[1] == 0) return pos;
        mx = max(mx, res[0] + res[1]);
        pos++;
    }

    while (pos < n){
        res = ASK(pos);
        if (res[0] + res[1] == 0) return pos;
        if (res[0] + res[1] < mx){
            pos++;
            continue;
        }

        int nxt = pos + 1;
        int l = pos + 1, r = n - 1;
        while (l <= r){
            int m = (l + r) >> 1;
            res = ASK(m);
            if (res[0] + res[1] == 0) return m;
            if (res[0] + res[1] < mx){
                r = m - 1;
                nxt = m;
            } else {
                auto tmp = ASK(pos);
                if (res[0] == tmp[0]) l = m + 1; else
                    r = m - 1;
                nxt = m + 1;
            }
        }

        pos = nxt;
    }

    return n / 2;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 11976 KB Output is correct
2 Correct 14 ms 12032 KB Output is correct
3 Correct 12 ms 11976 KB Output is correct
4 Correct 15 ms 11976 KB Output is correct
5 Correct 9 ms 12056 KB Output is correct
6 Correct 8 ms 12096 KB Output is correct
7 Correct 12 ms 11976 KB Output is correct
8 Correct 11 ms 11976 KB Output is correct
9 Correct 14 ms 12040 KB Output is correct
10 Correct 14 ms 11976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 12112 KB Output is correct
2 Correct 13 ms 12040 KB Output is correct
3 Correct 13 ms 12108 KB Output is correct
4 Correct 9 ms 12112 KB Output is correct
5 Correct 12 ms 12032 KB Output is correct
6 Correct 8 ms 12016 KB Output is correct
7 Correct 11 ms 12044 KB Output is correct
8 Correct 14 ms 12032 KB Output is correct
9 Correct 14 ms 12036 KB Output is correct
10 Correct 9 ms 12048 KB Output is correct
11 Correct 12 ms 12048 KB Output is correct
12 Correct 9 ms 12112 KB Output is correct
13 Correct 20 ms 11976 KB Output is correct
14 Correct 14 ms 11976 KB Output is correct
15 Correct 25 ms 12044 KB Output is correct
16 Partially correct 81 ms 12396 KB Partially correct - number of queries: 7230
17 Correct 13 ms 11976 KB Output is correct
18 Partially correct 79 ms 12224 KB Partially correct - number of queries: 8371
19 Correct 13 ms 12024 KB Output is correct
20 Correct 35 ms 12072 KB Output is correct
21 Correct 38 ms 12032 KB Output is correct
22 Correct 15 ms 11976 KB Output is correct
23 Correct 10 ms 12112 KB Output is correct
24 Correct 10 ms 12044 KB Output is correct
25 Correct 68 ms 12160 KB Output is correct
26 Correct 61 ms 12168 KB Output is correct
27 Correct 12 ms 12028 KB Output is correct
28 Partially correct 66 ms 12260 KB Partially correct - number of queries: 7910
29 Partially correct 82 ms 12096 KB Partially correct - number of queries: 6117
30 Partially correct 108 ms 12308 KB Partially correct - number of queries: 8324
31 Correct 12 ms 11976 KB Output is correct
32 Correct 11 ms 12048 KB Output is correct
33 Correct 8 ms 11976 KB Output is correct
34 Correct 42 ms 12012 KB Output is correct
35 Correct 11 ms 12048 KB Output is correct
36 Correct 25 ms 12132 KB Output is correct
37 Correct 17 ms 12024 KB Output is correct
38 Correct 13 ms 11976 KB Output is correct
39 Correct 57 ms 12032 KB Output is correct
40 Partially correct 87 ms 12224 KB Partially correct - number of queries: 7213
41 Partially correct 67 ms 12152 KB Partially correct - number of queries: 5208
42 Partially correct 71 ms 12152 KB Partially correct - number of queries: 5208
43 Correct 67 ms 12096 KB Output is correct
44 Correct 53 ms 12096 KB Output is correct
45 Correct 43 ms 12096 KB Output is correct
46 Correct 9 ms 12040 KB Output is correct
47 Correct 28 ms 12156 KB Output is correct
48 Partially correct 93 ms 12224 KB Partially correct - number of queries: 6335
49 Correct 24 ms 11952 KB Output is correct
50 Partially correct 47 ms 12392 KB Partially correct - number of queries: 8373
51 Correct 25 ms 12144 KB Output is correct
52 Correct 14 ms 12028 KB Output is correct
53 Correct 13 ms 12020 KB Output is correct
54 Correct 39 ms 12088 KB Output is correct
55 Correct 13 ms 11976 KB Output is correct
56 Partially correct 113 ms 12224 KB Partially correct - number of queries: 8373
57 Partially correct 66 ms 12160 KB Partially correct - number of queries: 6248
58 Partially correct 37 ms 12220 KB Partially correct - number of queries: 6321
59 Partially correct 60 ms 12148 KB Partially correct - number of queries: 5204
60 Correct 61 ms 12056 KB Output is correct
61 Correct 13 ms 12016 KB Output is correct
62 Correct 13 ms 11976 KB Output is correct
63 Correct 15 ms 11976 KB Output is correct
64 Correct 9 ms 12052 KB Output is correct
65 Correct 11 ms 12044 KB Output is correct
66 Correct 14 ms 12160 KB Output is correct
67 Correct 14 ms 11976 KB Output is correct
68 Correct 12 ms 11976 KB Output is correct
69 Correct 20 ms 12040 KB Output is correct
70 Correct 14 ms 12028 KB Output is correct
71 Partially correct 90 ms 12304 KB Partially correct - number of queries: 8239
72 Correct 17 ms 11976 KB Output is correct
73 Partially correct 94 ms 12260 KB Partially correct - number of queries: 8153
74 Partially correct 82 ms 12212 KB Partially correct - number of queries: 8197
75 Correct 15 ms 11976 KB Output is correct
76 Partially correct 72 ms 12228 KB Partially correct - number of queries: 7142
77 Partially correct 90 ms 12532 KB Partially correct - number of queries: 8400
78 Correct 21 ms 11976 KB Output is correct
79 Correct 55 ms 12140 KB Output is correct
80 Partially correct 115 ms 12360 KB Partially correct - number of queries: 8443
81 Partially correct 91 ms 12172 KB Partially correct - number of queries: 8406
82 Partially correct 82 ms 12180 KB Partially correct - number of queries: 8323
83 Correct 15 ms 12056 KB Output is correct
84 Partially correct 66 ms 12172 KB Partially correct - number of queries: 6940
85 Partially correct 75 ms 12556 KB Partially correct - number of queries: 8416
86 Correct 14 ms 11976 KB Output is correct
87 Correct 12 ms 11976 KB Output is correct
88 Correct 12 ms 12040 KB Output is correct
89 Correct 12 ms 12044 KB Output is correct
90 Correct 12 ms 12044 KB Output is correct
91 Correct 13 ms 12048 KB Output is correct
92 Correct 14 ms 11976 KB Output is correct
93 Correct 16 ms 12096 KB Output is correct
94 Correct 15 ms 12048 KB Output is correct
95 Correct 18 ms 12048 KB Output is correct
96 Correct 13 ms 11976 KB Output is correct
97 Correct 13 ms 11976 KB Output is correct