답안 #54024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54024 2018-07-02T08:33:29 Z chpipis 커다란 상품 (IOI17_prize) C++11
90 / 100
87 ms 1428 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;

int num_q;
map<int, vi> memo;

vi query(int x) {
    if (memo.count(x)) return memo[x];
    num_q++;
    vi ret = ask(x);
    return memo[x] = ret;
}

int find_best(int n) {
    memo.clear();
    num_q = 0;
    int mx = -1;
    for (int i = 0, j; i < n; i = j + 1) {
        if (i == n - 1) return i;
        j = i;
        vi cur = query(i);
        if (cur[0] + cur[1] == 0) return i;
        if (cur[0] + cur[1] < mx) continue;
        mx = max(mx, cur[0] + cur[1]);
        int lo = i + 1, hi = n - 1;
        while (lo <= hi) {
            int mid = (lo + hi) >> 1;
            vi now = query(mid);
            if (now[0] + now[1] == 0) return mid;
            if (now == cur) {
                lo = mid + 1;
                j = mid;
            } else {
                hi = mid - 1;
            }
        }
    }
}



Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 3 ms 312 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 520 KB Output is correct
7 Correct 2 ms 528 KB Output is correct
8 Correct 2 ms 528 KB Output is correct
9 Correct 2 ms 556 KB Output is correct
10 Correct 2 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 564 KB Output is correct
2 Correct 2 ms 564 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 2 ms 564 KB Output is correct
9 Correct 2 ms 568 KB Output is correct
10 Correct 2 ms 568 KB Output is correct
11 Correct 4 ms 568 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 4 ms 616 KB Output is correct
14 Correct 3 ms 616 KB Output is correct
15 Correct 11 ms 684 KB Output is correct
16 Partially correct 53 ms 1288 KB Partially correct - number of queries: 6747
17 Correct 2 ms 1288 KB Output is correct
18 Partially correct 62 ms 1428 KB Partially correct - number of queries: 7887
19 Correct 2 ms 1428 KB Output is correct
20 Correct 17 ms 1428 KB Output is correct
21 Correct 18 ms 1428 KB Output is correct
22 Correct 6 ms 1428 KB Output is correct
23 Correct 2 ms 1428 KB Output is correct
24 Correct 2 ms 1428 KB Output is correct
25 Correct 23 ms 1428 KB Output is correct
26 Correct 31 ms 1428 KB Output is correct
27 Correct 2 ms 1428 KB Output is correct
28 Partially correct 71 ms 1428 KB Partially correct - number of queries: 7428
29 Partially correct 28 ms 1428 KB Partially correct - number of queries: 5636
30 Partially correct 67 ms 1428 KB Partially correct - number of queries: 7844
31 Correct 2 ms 1428 KB Output is correct
32 Correct 4 ms 1428 KB Output is correct
33 Correct 3 ms 1428 KB Output is correct
34 Correct 20 ms 1428 KB Output is correct
35 Correct 3 ms 1428 KB Output is correct
36 Correct 17 ms 1428 KB Output is correct
37 Correct 3 ms 1428 KB Output is correct
38 Correct 2 ms 1428 KB Output is correct
39 Correct 25 ms 1428 KB Output is correct
40 Partially correct 81 ms 1428 KB Partially correct - number of queries: 6730
41 Correct 29 ms 1428 KB Output is correct
42 Correct 40 ms 1428 KB Output is correct
43 Correct 25 ms 1428 KB Output is correct
44 Correct 25 ms 1428 KB Output is correct
45 Correct 20 ms 1428 KB Output is correct
46 Correct 4 ms 1428 KB Output is correct
47 Correct 20 ms 1428 KB Output is correct
48 Partially correct 52 ms 1428 KB Partially correct - number of queries: 5851
49 Correct 4 ms 1428 KB Output is correct
50 Partially correct 38 ms 1428 KB Partially correct - number of queries: 7890
51 Correct 31 ms 1428 KB Output is correct
52 Correct 3 ms 1428 KB Output is correct
53 Correct 5 ms 1428 KB Output is correct
54 Correct 30 ms 1428 KB Output is correct
55 Correct 2 ms 1428 KB Output is correct
56 Partially correct 61 ms 1428 KB Partially correct - number of queries: 7890
57 Partially correct 62 ms 1428 KB Partially correct - number of queries: 5767
58 Partially correct 58 ms 1428 KB Partially correct - number of queries: 5839
59 Correct 34 ms 1428 KB Output is correct
60 Correct 37 ms 1428 KB Output is correct
61 Correct 3 ms 1428 KB Output is correct
62 Correct 2 ms 1428 KB Output is correct
63 Correct 5 ms 1428 KB Output is correct
64 Correct 3 ms 1428 KB Output is correct
65 Correct 2 ms 1428 KB Output is correct
66 Correct 8 ms 1428 KB Output is correct
67 Correct 3 ms 1428 KB Output is correct
68 Correct 2 ms 1428 KB Output is correct
69 Correct 5 ms 1428 KB Output is correct
70 Correct 2 ms 1428 KB Output is correct
71 Partially correct 70 ms 1428 KB Partially correct - number of queries: 7757
72 Correct 7 ms 1428 KB Output is correct
73 Partially correct 68 ms 1428 KB Partially correct - number of queries: 7648
74 Partially correct 66 ms 1428 KB Partially correct - number of queries: 7690
75 Correct 3 ms 1428 KB Output is correct
76 Partially correct 42 ms 1428 KB Partially correct - number of queries: 6628
77 Partially correct 87 ms 1428 KB Partially correct - number of queries: 7919
78 Correct 5 ms 1428 KB Output is correct
79 Correct 22 ms 1428 KB Output is correct
80 Partially correct 70 ms 1428 KB Partially correct - number of queries: 7911
81 Partially correct 45 ms 1428 KB Partially correct - number of queries: 7936
82 Partially correct 85 ms 1428 KB Partially correct - number of queries: 7882
83 Correct 4 ms 1428 KB Output is correct
84 Partially correct 38 ms 1428 KB Partially correct - number of queries: 6461
85 Partially correct 70 ms 1428 KB Partially correct - number of queries: 7913
86 Partially correct 37 ms 1428 KB Partially correct - number of queries: 6042
87 Correct 4 ms 1428 KB Output is correct
88 Partially correct 55 ms 1428 KB Partially correct - number of queries: 5708
89 Partially correct 69 ms 1428 KB Partially correct - number of queries: 5979
90 Correct 3 ms 1428 KB Output is correct
91 Correct 25 ms 1428 KB Output is correct
92 Correct 2 ms 1428 KB Output is correct
93 Correct 4 ms 1428 KB Output is correct
94 Correct 6 ms 1428 KB Output is correct
95 Correct 6 ms 1428 KB Output is correct
96 Correct 6 ms 1428 KB Output is correct
97 Correct 3 ms 1428 KB Output is correct