Submission #1030333

# Submission time Handle Problem Language Result Execution time Memory
1030333 2024-07-22T02:51:44 Z shiomusubi496 The Big Prize (IOI17_prize) C++17
20 / 100
54 ms 5760 KB
#include "prize.h"

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)

#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)

using namespace std;

using ll = long long;

template<class T, class U> bool chmin(T& a, const U& b) { return a > b ? a = b, true : false; }
template<class T, class U> bool chmax(T& a, const U& b) { return a < b ? a = b, true : false; }

vector<vector<int>> memo;
vector<int> Ask(int n) {
    if (memo[n].empty()) memo[n] = ask(n);
    return memo[n];
}

int find_best(int n) {
    memo.resize(n);
    int cnt = 0;
    rep (i, 1) {
        auto res = Ask(i);
        chmax(cnt, res[0] + res[1]);
        if (res[0] + res[1] == 0) return i;
    }
    int x = 1;
    while (x < n) {
        int y = 0;
        while (x < n) {
            auto res = Ask(x);
            if (res[0] + res[1] == 0) return x;
            if (res[0] + res[1] == cnt) {
                y = res[0];
                break;
            }
            ++x;
        }
        int ok = x, ng = n;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            auto res = Ask(mid);
            if (res[0] + res[1] == 0) return mid;
            if (res[0] + res[1] < cnt) ng = mid;
            else if (res[0] > y) ng = mid;
            else ok = mid;
        }
        x = ok + 1;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 3 ms 4952 KB Output is correct
5 Correct 3 ms 4952 KB Output is correct
6 Correct 3 ms 4952 KB Output is correct
7 Correct 3 ms 4952 KB Output is correct
8 Correct 3 ms 4952 KB Output is correct
9 Correct 3 ms 4952 KB Output is correct
10 Correct 3 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 3 ms 4952 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 3 ms 4952 KB Output is correct
5 Correct 2 ms 4952 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 4 ms 4952 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 3 ms 4952 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 4 ms 4952 KB Output is correct
12 Correct 3 ms 4952 KB Output is correct
13 Correct 5 ms 4952 KB Output is correct
14 Correct 2 ms 856 KB Output is correct
15 Correct 11 ms 5040 KB Output is correct
16 Partially correct 37 ms 5452 KB Partially correct - number of queries: 6749
17 Correct 3 ms 4952 KB Output is correct
18 Partially correct 54 ms 5200 KB Partially correct - number of queries: 7889
19 Correct 2 ms 4952 KB Output is correct
20 Correct 12 ms 2648 KB Output is correct
21 Correct 19 ms 5208 KB Output is correct
22 Correct 4 ms 4952 KB Output is correct
23 Correct 3 ms 4952 KB Output is correct
24 Correct 3 ms 4952 KB Output is correct
25 Correct 33 ms 5208 KB Output is correct
26 Correct 22 ms 5200 KB Output is correct
27 Correct 3 ms 4952 KB Output is correct
28 Partially correct 43 ms 5496 KB Partially correct - number of queries: 7430
29 Partially correct 38 ms 5456 KB Partially correct - number of queries: 5638
30 Partially correct 46 ms 5556 KB Partially correct - number of queries: 7845
31 Correct 2 ms 4952 KB Output is correct
32 Correct 4 ms 4952 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 14 ms 5032 KB Output is correct
35 Correct 4 ms 4952 KB Output is correct
36 Correct 17 ms 5208 KB Output is correct
37 Correct 3 ms 4952 KB Output is correct
38 Correct 2 ms 4952 KB Output is correct
39 Correct 30 ms 5456 KB Output is correct
40 Partially correct 51 ms 5456 KB Partially correct - number of queries: 6732
41 Correct 31 ms 5468 KB Output is correct
42 Correct 28 ms 5456 KB Output is correct
43 Correct 20 ms 5472 KB Output is correct
44 Correct 16 ms 5208 KB Output is correct
45 Correct 13 ms 5204 KB Output is correct
46 Correct 3 ms 4956 KB Output is correct
47 Correct 19 ms 5172 KB Output is correct
48 Partially correct 46 ms 5452 KB Partially correct - number of queries: 5853
49 Correct 4 ms 4952 KB Output is correct
50 Partially correct 44 ms 5760 KB Partially correct - number of queries: 7892
51 Correct 22 ms 5208 KB Output is correct
52 Correct 3 ms 4952 KB Output is correct
53 Correct 3 ms 4948 KB Output is correct
54 Correct 16 ms 5208 KB Output is correct
55 Correct 3 ms 4952 KB Output is correct
56 Partially correct 47 ms 5208 KB Partially correct - number of queries: 7892
57 Partially correct 46 ms 5208 KB Partially correct - number of queries: 5767
58 Partially correct 32 ms 5484 KB Partially correct - number of queries: 5840
59 Correct 19 ms 5204 KB Output is correct
60 Correct 30 ms 5208 KB Output is correct
61 Correct 3 ms 5148 KB Output is correct
62 Correct 3 ms 4952 KB Output is correct
63 Correct 3 ms 4952 KB Output is correct
64 Correct 2 ms 4952 KB Output is correct
65 Incorrect 42 ms 5612 KB Incorrect
66 Halted 0 ms 0 KB -