답안 #293137

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
293137 2020-09-07T16:45:14 Z Saboon 커다란 상품 (IOI17_prize) C++17
96.27 / 100
85 ms 7344 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int Max = 0;
const int maxn = 2e5 + 10;
vector<int> Q[maxn];
bool mark[maxn];
 
vector<int> Ask(int i){
    if (mark[i])
        return Q[i];
    mark[i] = 1;
    return Q[i] = ask(i);
}
 
int solve(int l, int r, int cnt, int pre = 0, int suf = 0){
    if (cnt <= 0 or l >= r)
        return -1;
    if (l+1 == r){
        vector<int> res = Ask(l);
        if (res[0]+res[1] == 0)
            return l;
        return -1;
    }
    vector<int> Vals;
    int m = (l+r)>>1;
    Vals.push_back(m);
    for (int i = 1; ;i++){
        bool found = 0;
        if (m+i < r)
            found = 1, Vals.push_back(m+i);
        if (m-i >= l)
            found = 1, Vals.push_back(m-i);
        if (!found)
            break;
    }
    for (auto mid : Vals){
        vector<int> res = Ask(mid);
        if (res[0]+res[1] == 0)
            return mid;
        if (res[0]+res[1] == Max){
            int ret = solve(l,mid,res[0]-pre, pre, res[1]);
            if (ret != -1)
                return ret;
            return solve(mid+1, r, res[1]-suf, res[0], suf);
        }
    }
    return -1;
}
 
int find_best(int n){
    for (int i = 0; i < min(n,480); i++){
        vector<int> res = Ask(i);
        Max = max(Max, res[0]+res[1]);
        if (Max >= 480)
            break;
    }
    return solve(0, n, Max);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 6900 KB Output is correct
2 Correct 13 ms 6892 KB Output is correct
3 Correct 12 ms 7020 KB Output is correct
4 Correct 10 ms 6892 KB Output is correct
5 Correct 12 ms 6256 KB Output is correct
6 Correct 9 ms 7036 KB Output is correct
7 Correct 10 ms 6256 KB Output is correct
8 Correct 8 ms 6280 KB Output is correct
9 Correct 11 ms 6892 KB Output is correct
10 Correct 12 ms 6892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 6900 KB Output is correct
2 Correct 12 ms 6892 KB Output is correct
3 Correct 12 ms 6900 KB Output is correct
4 Correct 11 ms 7020 KB Output is correct
5 Correct 9 ms 6256 KB Output is correct
6 Correct 12 ms 6892 KB Output is correct
7 Correct 10 ms 6264 KB Output is correct
8 Correct 12 ms 6256 KB Output is correct
9 Correct 13 ms 6892 KB Output is correct
10 Correct 13 ms 6900 KB Output is correct
11 Correct 15 ms 7020 KB Output is correct
12 Correct 10 ms 7020 KB Output is correct
13 Correct 21 ms 7020 KB Output is correct
14 Correct 11 ms 5248 KB Output is correct
15 Correct 23 ms 7020 KB Output is correct
16 Correct 65 ms 7276 KB Output is correct
17 Correct 12 ms 6976 KB Output is correct
18 Partially correct 70 ms 7344 KB Partially correct - number of queries: 5241
19 Correct 13 ms 6900 KB Output is correct
20 Correct 24 ms 6136 KB Output is correct
21 Correct 33 ms 7020 KB Output is correct
22 Correct 14 ms 6900 KB Output is correct
23 Correct 12 ms 6892 KB Output is correct
24 Correct 13 ms 6900 KB Output is correct
25 Correct 27 ms 7156 KB Output is correct
26 Correct 42 ms 7020 KB Output is correct
27 Correct 15 ms 7020 KB Output is correct
28 Correct 71 ms 7060 KB Output is correct
29 Correct 52 ms 7120 KB Output is correct
30 Partially correct 65 ms 7140 KB Partially correct - number of queries: 5205
31 Correct 12 ms 6892 KB Output is correct
32 Correct 18 ms 7148 KB Output is correct
33 Correct 6 ms 4992 KB Output is correct
34 Correct 30 ms 7024 KB Output is correct
35 Correct 17 ms 7028 KB Output is correct
36 Correct 28 ms 7028 KB Output is correct
37 Correct 15 ms 7020 KB Output is correct
38 Correct 13 ms 6900 KB Output is correct
39 Correct 44 ms 7020 KB Output is correct
40 Correct 58 ms 7108 KB Output is correct
41 Correct 42 ms 7020 KB Output is correct
42 Correct 45 ms 7020 KB Output is correct
43 Correct 35 ms 7148 KB Output is correct
44 Correct 32 ms 7020 KB Output is correct
45 Correct 23 ms 7020 KB Output is correct
46 Correct 11 ms 6892 KB Output is correct
47 Correct 35 ms 7024 KB Output is correct
48 Correct 50 ms 7020 KB Output is correct
49 Correct 17 ms 7020 KB Output is correct
50 Partially correct 81 ms 7276 KB Partially correct - number of queries: 5232
51 Correct 38 ms 7088 KB Output is correct
52 Correct 13 ms 6892 KB Output is correct
53 Correct 17 ms 7092 KB Output is correct
54 Correct 41 ms 7024 KB Output is correct
55 Correct 14 ms 6968 KB Output is correct
56 Partially correct 46 ms 7156 KB Partially correct - number of queries: 5242
57 Correct 69 ms 7188 KB Output is correct
58 Correct 62 ms 7148 KB Output is correct
59 Correct 54 ms 7064 KB Output is correct
60 Correct 47 ms 7044 KB Output is correct
61 Correct 17 ms 7068 KB Output is correct
62 Correct 14 ms 6972 KB Output is correct
63 Correct 16 ms 7016 KB Output is correct
64 Correct 14 ms 7020 KB Output is correct
65 Correct 12 ms 6892 KB Output is correct
66 Correct 18 ms 6892 KB Output is correct
67 Correct 16 ms 6968 KB Output is correct
68 Correct 12 ms 6892 KB Output is correct
69 Correct 17 ms 7020 KB Output is correct
70 Correct 14 ms 6968 KB Output is correct
71 Partially correct 85 ms 7144 KB Partially correct - number of queries: 5238
72 Correct 24 ms 7020 KB Output is correct
73 Partially correct 73 ms 7104 KB Partially correct - number of queries: 5175
74 Partially correct 68 ms 7020 KB Partially correct - number of queries: 5202
75 Correct 16 ms 7076 KB Output is correct
76 Correct 82 ms 7232 KB Output is correct
77 Partially correct 79 ms 7192 KB Partially correct - number of queries: 5373
78 Correct 23 ms 7020 KB Output is correct
79 Correct 51 ms 7272 KB Output is correct
80 Partially correct 71 ms 7236 KB Partially correct - number of queries: 5336
81 Partially correct 77 ms 7132 KB Partially correct - number of queries: 5348
82 Partially correct 80 ms 7276 KB Partially correct - number of queries: 5302
83 Correct 16 ms 7068 KB Output is correct
84 Correct 57 ms 7208 KB Output is correct
85 Partially correct 78 ms 7296 KB Partially correct - number of queries: 5320
86 Correct 13 ms 6900 KB Output is correct
87 Correct 15 ms 6892 KB Output is correct
88 Correct 13 ms 6968 KB Output is correct
89 Correct 14 ms 7116 KB Output is correct
90 Correct 15 ms 6892 KB Output is correct
91 Correct 12 ms 6900 KB Output is correct
92 Correct 15 ms 6896 KB Output is correct
93 Correct 19 ms 7020 KB Output is correct
94 Correct 18 ms 7028 KB Output is correct
95 Correct 19 ms 7068 KB Output is correct
96 Correct 18 ms 7064 KB Output is correct
97 Correct 13 ms 6900 KB Output is correct