답안 #1065439

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065439 2024-08-19T07:38:00 Z TheQuantiX 커다란 상품 (IOI17_prize) C++17
20 / 100
64 ms 1980 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 < 3; 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;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 1 ms 1880 KB Output is correct
4 Correct 2 ms 1880 KB Output is correct
5 Correct 1 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 KB Output is correct
3 Correct 1 ms 1880 KB Output is correct
4 Correct 1 ms 1880 KB Output is correct
5 Correct 1 ms 1880 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1880 KB Output is correct
8 Correct 2 ms 1880 KB Output is correct
9 Correct 1 ms 1880 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
11 Correct 2 ms 1880 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 3 ms 1880 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 7 ms 1976 KB Output is correct
16 Partially correct 30 ms 1880 KB Partially correct - number of queries: 6664
17 Correct 1 ms 1880 KB Output is correct
18 Partially correct 50 ms 1880 KB Partially correct - number of queries: 7805
19 Correct 1 ms 1880 KB Output is correct
20 Correct 11 ms 1112 KB Output is correct
21 Correct 15 ms 1880 KB Output is correct
22 Correct 3 ms 1880 KB Output is correct
23 Correct 1 ms 1880 KB Output is correct
24 Correct 1 ms 1880 KB Output is correct
25 Correct 28 ms 1880 KB Output is correct
26 Correct 27 ms 1880 KB Output is correct
27 Correct 1 ms 1880 KB Output is correct
28 Partially correct 54 ms 1880 KB Partially correct - number of queries: 7364
29 Partially correct 34 ms 1880 KB Partially correct - number of queries: 5584
30 Partially correct 48 ms 1880 KB Partially correct - number of queries: 7761
31 Correct 1 ms 1880 KB Output is correct
32 Correct 4 ms 1880 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 9 ms 1880 KB Output is correct
35 Correct 2 ms 1880 KB Output is correct
36 Correct 9 ms 1880 KB Output is correct
37 Correct 2 ms 1880 KB Output is correct
38 Correct 1 ms 1880 KB Output is correct
39 Correct 22 ms 1980 KB Output is correct
40 Partially correct 34 ms 1880 KB Partially correct - number of queries: 6639
41 Correct 26 ms 1880 KB Output is correct
42 Correct 14 ms 1876 KB Output is correct
43 Correct 32 ms 1880 KB Output is correct
44 Correct 10 ms 1880 KB Output is correct
45 Correct 13 ms 1880 KB Output is correct
46 Correct 1 ms 1880 KB Output is correct
47 Correct 15 ms 1880 KB Output is correct
48 Partially correct 31 ms 1880 KB Partially correct - number of queries: 5797
49 Correct 5 ms 1880 KB Output is correct
50 Partially correct 36 ms 1880 KB Partially correct - number of queries: 7800
51 Correct 13 ms 1880 KB Output is correct
52 Correct 1 ms 1880 KB Output is correct
53 Correct 2 ms 1880 KB Output is correct
54 Correct 16 ms 1880 KB Output is correct
55 Correct 1 ms 1880 KB Output is correct
56 Partially correct 45 ms 1880 KB Partially correct - number of queries: 7806
57 Partially correct 33 ms 1880 KB Partially correct - number of queries: 5683
58 Partially correct 38 ms 1880 KB Partially correct - number of queries: 5775
59 Correct 32 ms 1876 KB Output is correct
60 Correct 19 ms 1880 KB Output is correct
61 Correct 1 ms 1880 KB Output is correct
62 Correct 1 ms 1876 KB Output is correct
63 Correct 2 ms 1880 KB Output is correct
64 Correct 1 ms 1880 KB Output is correct
65 Correct 1 ms 1880 KB Output is correct
66 Correct 3 ms 1880 KB Output is correct
67 Correct 1 ms 1880 KB Output is correct
68 Correct 3 ms 1880 KB Output is correct
69 Correct 2 ms 1880 KB Output is correct
70 Correct 1 ms 1880 KB Output is correct
71 Partially correct 32 ms 1880 KB Partially correct - number of queries: 7829
72 Correct 2 ms 1880 KB Output is correct
73 Partially correct 45 ms 1880 KB Partially correct - number of queries: 7700
74 Partially correct 37 ms 1880 KB Partially correct - number of queries: 7767
75 Correct 1 ms 1880 KB Output is correct
76 Partially correct 39 ms 1880 KB Partially correct - number of queries: 6628
77 Partially correct 46 ms 1880 KB Partially correct - number of queries: 7894
78 Correct 5 ms 1880 KB Output is correct
79 Correct 18 ms 1880 KB Output is correct
80 Partially correct 38 ms 1880 KB Partially correct - number of queries: 7880
81 Partially correct 52 ms 1880 KB Partially correct - number of queries: 7860
82 Partially correct 42 ms 1880 KB Partially correct - number of queries: 7821
83 Correct 2 ms 1880 KB Output is correct
84 Partially correct 34 ms 1880 KB Partially correct - number of queries: 6450
85 Partially correct 39 ms 1880 KB Partially correct - number of queries: 7879
86 Incorrect 64 ms 1880 KB Incorrect
87 Halted 0 ms 0 KB -