답안 #1065454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065454 2024-08-19T07:48:18 Z TheQuantiX 커다란 상품 (IOI17_prize) C++17
90 / 100
58 ms 2132 KB
#include <bits/stdc++.h>
#include "prize.h"

using namespace std;
using ll = long long;

pair<int, int> memo[200001];
ll p = 0;

pair<ll, ll> doask(int i) {
    if (memo[i].first != -1) {
        return memo[i];
    }
    auto v = ask(i);
    memo[i] = {v[0], v[1]};
    return memo[i];
}

int find_best(int n) {
    mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
    for (int i = 0; i < n; i++) {
        memo[i] = {-1, -1};
    }
    for (int i = 0; i < 500; i++) {
        ll x = gen() % n;
        p = max(p, doask(x).first + doask(x).second);
        if (doask(x).first + doask(x).second == 0) {
            return x;
        }
    }
    ll x = 0;
    while (x != n) {
        if (doask(x).first + doask(x).second != p) {
            if (doask(x).first + doask(x).second == 0) {
                return x;
            }
            x++;
            continue;
        }
        ll l = x, r = n - 1;
        while (r > l) {
            ll mid = (l + r) / 2;
            if (doask(mid) != doask(x)) {
                r = mid;
            }
            else {
                l = mid + 1;
            }
        }
        if (doask(l).first + doask(l).second == 0) {
            return l;
        }
        x = r + 1;
    }
    assert(false);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1880 KB Output is correct
2 Correct 4 ms 1880 KB Output is correct
3 Correct 5 ms 1880 KB Output is correct
4 Correct 4 ms 1880 KB Output is correct
5 Correct 3 ms 1880 KB Output is correct
6 Correct 3 ms 1880 KB Output is correct
7 Correct 3 ms 1880 KB Output is correct
8 Correct 3 ms 1880 KB Output is correct
9 Correct 3 ms 1880 KB Output is correct
10 Correct 3 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1880 KB Output is correct
2 Correct 3 ms 1880 KB Output is correct
3 Correct 3 ms 1880 KB Output is correct
4 Correct 3 ms 1880 KB Output is correct
5 Correct 3 ms 1880 KB Output is correct
6 Correct 4 ms 1880 KB Output is correct
7 Correct 3 ms 1880 KB Output is correct
8 Correct 3 ms 1880 KB Output is correct
9 Correct 3 ms 1880 KB Output is correct
10 Correct 4 ms 1880 KB Output is correct
11 Correct 4 ms 1880 KB Output is correct
12 Correct 2 ms 1880 KB Output is correct
13 Correct 8 ms 1880 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 12 ms 1972 KB Output is correct
16 Partially correct 31 ms 1880 KB Partially correct - number of queries: 7141
17 Correct 3 ms 1880 KB Output is correct
18 Partially correct 28 ms 1880 KB Partially correct - number of queries: 8284
19 Correct 3 ms 1880 KB Output is correct
20 Correct 11 ms 1112 KB Output is correct
21 Correct 14 ms 1880 KB Output is correct
22 Correct 5 ms 1880 KB Output is correct
23 Correct 3 ms 1880 KB Output is correct
24 Correct 3 ms 1880 KB Output is correct
25 Correct 23 ms 1880 KB Output is correct
26 Correct 21 ms 1880 KB Output is correct
27 Correct 5 ms 1880 KB Output is correct
28 Partially correct 54 ms 1880 KB Partially correct - number of queries: 7838
29 Partially correct 32 ms 1880 KB Partially correct - number of queries: 6070
30 Partially correct 37 ms 1880 KB Partially correct - number of queries: 8237
31 Correct 3 ms 1880 KB Output is correct
32 Correct 6 ms 1880 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 10 ms 1880 KB Output is correct
35 Correct 3 ms 1880 KB Output is correct
36 Correct 11 ms 1880 KB Output is correct
37 Correct 4 ms 1880 KB Output is correct
38 Correct 4 ms 1880 KB Output is correct
39 Correct 31 ms 1880 KB Output is correct
40 Partially correct 58 ms 1880 KB Partially correct - number of queries: 7116
41 Partially correct 31 ms 1876 KB Partially correct - number of queries: 5175
42 Partially correct 34 ms 1876 KB Partially correct - number of queries: 5184
43 Correct 19 ms 1880 KB Output is correct
44 Correct 18 ms 1880 KB Output is correct
45 Correct 13 ms 1880 KB Output is correct
46 Correct 3 ms 1880 KB Output is correct
47 Correct 22 ms 1880 KB Output is correct
48 Partially correct 45 ms 1880 KB Partially correct - number of queries: 6281
49 Correct 5 ms 1880 KB Output is correct
50 Partially correct 36 ms 1880 KB Partially correct - number of queries: 8271
51 Correct 20 ms 1880 KB Output is correct
52 Correct 3 ms 1880 KB Output is correct
53 Correct 3 ms 1880 KB Output is correct
54 Correct 23 ms 1880 KB Output is correct
55 Correct 4 ms 1880 KB Output is correct
56 Partially correct 41 ms 1880 KB Partially correct - number of queries: 8282
57 Partially correct 19 ms 1880 KB Partially correct - number of queries: 6164
58 Partially correct 43 ms 1880 KB Partially correct - number of queries: 6262
59 Partially correct 24 ms 1880 KB Partially correct - number of queries: 5179
60 Correct 22 ms 1880 KB Output is correct
61 Correct 4 ms 1880 KB Output is correct
62 Correct 4 ms 1880 KB Output is correct
63 Correct 4 ms 1880 KB Output is correct
64 Correct 4 ms 1976 KB Output is correct
65 Correct 5 ms 1880 KB Output is correct
66 Correct 6 ms 1880 KB Output is correct
67 Correct 4 ms 1880 KB Output is correct
68 Correct 5 ms 1880 KB Output is correct
69 Correct 5 ms 2132 KB Output is correct
70 Correct 4 ms 1880 KB Output is correct
71 Partially correct 44 ms 2132 KB Partially correct - number of queries: 8329
72 Correct 5 ms 1880 KB Output is correct
73 Partially correct 39 ms 1880 KB Partially correct - number of queries: 8204
74 Partially correct 54 ms 2132 KB Partially correct - number of queries: 8254
75 Correct 4 ms 1880 KB Output is correct
76 Partially correct 38 ms 1880 KB Partially correct - number of queries: 7139
77 Partially correct 55 ms 1880 KB Partially correct - number of queries: 8366
78 Correct 10 ms 1880 KB Output is correct
79 Correct 15 ms 1880 KB Output is correct
80 Partially correct 50 ms 1880 KB Partially correct - number of queries: 8395
81 Partially correct 44 ms 1880 KB Partially correct - number of queries: 8399
82 Partially correct 44 ms 1880 KB Partially correct - number of queries: 8319
83 Correct 3 ms 1880 KB Output is correct
84 Partially correct 24 ms 1880 KB Partially correct - number of queries: 6936
85 Partially correct 53 ms 1880 KB Partially correct - number of queries: 8388
86 Partially correct 41 ms 1880 KB Partially correct - number of queries: 6953
87 Correct 5 ms 1880 KB Output is correct
88 Partially correct 33 ms 1880 KB Partially correct - number of queries: 6176
89 Correct 19 ms 1880 KB Output is correct
90 Correct 3 ms 1880 KB Output is correct
91 Correct 9 ms 1880 KB Output is correct
92 Correct 8 ms 1880 KB Output is correct
93 Partially correct 52 ms 1880 KB Partially correct - number of queries: 7445
94 Partially correct 32 ms 1880 KB Partially correct - number of queries: 7817
95 Partially correct 41 ms 1880 KB Partially correct - number of queries: 7717
96 Partially correct 54 ms 1880 KB Partially correct - number of queries: 7734
97 Partially correct 31 ms 1880 KB Partially correct - number of queries: 7086