답안 #316224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316224 2020-10-25T17:36:32 Z nikatamliani 커다란 상품 (IOI17_prize) C++14
94.89 / 100
69 ms 5260 KB
#include <bits/stdc++.h>
using namespace std;
#include "prize.h"
vector < vector < int > > memo;
vector < int > memo_ask(int x) {
    if(!memo[x].empty()) return memo[x];
    return memo[x] = ask(x);
}
int find_best(int n) {
    int next = -1, at_most = min(472, n - 1);
    const int BLOCK_SIZE = 500;
    vector < int > bad(2); 
    memo.resize(n);
    for(int i = 0; i <= at_most; ++i) {
        vector < int > cur = memo_ask(i);
        if(bad[0] + bad[1] < cur[0] + cur[1]) bad = cur;
        if(cur[0] == 0 && cur[1] == 0) return i;
    }
    for(int i = at_most + 1; i < n; i = next + 1) {
        int l = i, r = n - 1; next = -1;
        vector < int > t = memo_ask(i);
        if(t[0] + t[1] != bad[0] + bad[1]) {
            next = i;
            if(t[0] == 0 && t[1] == 0) return i; 
            continue;
        } 
        int maybe = i + BLOCK_SIZE;
        if(maybe < n && memo_ask(maybe) == t) {
            next = maybe;
            continue;
        }
        if(maybe < n) r = maybe - 1;
        while(r >= l) {
            int m = l + r >> 1;
            vector < int > x = memo_ask(m);
            if(x == t) {
                next = m;
                l = m + 1;
            } else {
                r = m - 1; 
            }
        }
        assert(next >= i);
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:34:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |             int m = l + r >> 1;
      |                     ~~^~~
prize.cpp:12:25: warning: control reaches end of non-void function [-Wreturn-type]
   12 |     vector < int > bad(2);
      |                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4992 KB Output is correct
2 Correct 12 ms 4984 KB Output is correct
3 Correct 12 ms 4992 KB Output is correct
4 Correct 11 ms 5112 KB Output is correct
5 Correct 13 ms 4992 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 11 ms 4992 KB Output is correct
8 Correct 14 ms 4992 KB Output is correct
9 Correct 14 ms 4992 KB Output is correct
10 Correct 15 ms 5112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4984 KB Output is correct
2 Correct 13 ms 4992 KB Output is correct
3 Correct 11 ms 5112 KB Output is correct
4 Correct 16 ms 5112 KB Output is correct
5 Correct 9 ms 5248 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 14 ms 4992 KB Output is correct
8 Correct 15 ms 4992 KB Output is correct
9 Correct 15 ms 4992 KB Output is correct
10 Correct 15 ms 5112 KB Output is correct
11 Correct 13 ms 4992 KB Output is correct
12 Correct 9 ms 4992 KB Output is correct
13 Correct 23 ms 5112 KB Output is correct
14 Correct 8 ms 896 KB Output is correct
15 Correct 18 ms 5112 KB Output is correct
16 Correct 49 ms 5112 KB Output is correct
17 Correct 8 ms 4984 KB Output is correct
18 Partially correct 47 ms 5260 KB Partially correct - number of queries: 5480
19 Correct 7 ms 5120 KB Output is correct
20 Correct 17 ms 2688 KB Output is correct
21 Correct 24 ms 5112 KB Output is correct
22 Correct 12 ms 4992 KB Output is correct
23 Correct 11 ms 4992 KB Output is correct
24 Correct 9 ms 5024 KB Output is correct
25 Correct 35 ms 5112 KB Output is correct
26 Correct 35 ms 5112 KB Output is correct
27 Correct 12 ms 4992 KB Output is correct
28 Partially correct 57 ms 5240 KB Partially correct - number of queries: 5490
29 Correct 62 ms 5112 KB Output is correct
30 Partially correct 53 ms 5240 KB Partially correct - number of queries: 5511
31 Correct 9 ms 4992 KB Output is correct
32 Correct 15 ms 5112 KB Output is correct
33 Correct 0 ms 256 KB Output is correct
34 Correct 22 ms 5092 KB Output is correct
35 Correct 13 ms 5112 KB Output is correct
36 Correct 24 ms 5112 KB Output is correct
37 Correct 10 ms 4984 KB Output is correct
38 Correct 11 ms 4984 KB Output is correct
39 Correct 30 ms 5112 KB Output is correct
40 Correct 51 ms 5148 KB Output is correct
41 Correct 25 ms 5136 KB Output is correct
42 Correct 38 ms 5112 KB Output is correct
43 Correct 38 ms 5112 KB Output is correct
44 Correct 27 ms 5248 KB Output is correct
45 Correct 28 ms 5112 KB Output is correct
46 Correct 9 ms 4984 KB Output is correct
47 Correct 37 ms 5112 KB Output is correct
48 Correct 40 ms 5116 KB Output is correct
49 Correct 15 ms 4992 KB Output is correct
50 Partially correct 51 ms 5240 KB Partially correct - number of queries: 5462
51 Correct 35 ms 5240 KB Output is correct
52 Correct 9 ms 4992 KB Output is correct
53 Correct 20 ms 5104 KB Output is correct
54 Correct 36 ms 5120 KB Output is correct
55 Correct 7 ms 4984 KB Output is correct
56 Partially correct 57 ms 5240 KB Partially correct - number of queries: 5474
57 Correct 34 ms 5112 KB Output is correct
58 Correct 25 ms 5180 KB Output is correct
59 Correct 42 ms 5112 KB Output is correct
60 Correct 26 ms 5176 KB Output is correct
61 Correct 20 ms 5112 KB Output is correct
62 Correct 11 ms 4992 KB Output is correct
63 Correct 19 ms 5112 KB Output is correct
64 Correct 16 ms 4992 KB Output is correct
65 Correct 20 ms 5112 KB Output is correct
66 Correct 25 ms 5112 KB Output is correct
67 Correct 18 ms 5112 KB Output is correct
68 Correct 6 ms 4992 KB Output is correct
69 Correct 25 ms 5128 KB Output is correct
70 Correct 20 ms 5112 KB Output is correct
71 Partially correct 60 ms 5240 KB Partially correct - number of queries: 5193
72 Correct 24 ms 5240 KB Output is correct
73 Partially correct 69 ms 5240 KB Partially correct - number of queries: 5123
74 Partially correct 64 ms 5112 KB Partially correct - number of queries: 5153
75 Correct 20 ms 5112 KB Output is correct
76 Correct 57 ms 5240 KB Output is correct
77 Partially correct 55 ms 5240 KB Partially correct - number of queries: 5435
78 Correct 19 ms 5120 KB Output is correct
79 Correct 32 ms 5244 KB Output is correct
80 Partially correct 67 ms 5240 KB Partially correct - number of queries: 5438
81 Partially correct 52 ms 5244 KB Partially correct - number of queries: 5407
82 Partially correct 58 ms 5240 KB Partially correct - number of queries: 5377
83 Correct 14 ms 5112 KB Output is correct
84 Correct 31 ms 5240 KB Output is correct
85 Partially correct 41 ms 5240 KB Partially correct - number of queries: 5384
86 Correct 14 ms 5120 KB Output is correct
87 Correct 16 ms 5100 KB Output is correct
88 Correct 14 ms 4992 KB Output is correct
89 Correct 18 ms 5112 KB Output is correct
90 Correct 15 ms 4992 KB Output is correct
91 Correct 15 ms 4992 KB Output is correct
92 Correct 15 ms 4992 KB Output is correct
93 Correct 22 ms 5112 KB Output is correct
94 Correct 18 ms 5084 KB Output is correct
95 Correct 11 ms 5164 KB Output is correct
96 Correct 17 ms 5112 KB Output is correct
97 Correct 14 ms 5112 KB Output is correct