답안 #668887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668887 2022-12-05T06:46:57 Z a_aguilo 커다란 상품 (IOI17_prize) C++14
90 / 100
54 ms 2000 KB
#include "prize.h"
#include<bits/stdc++.h>

using namespace std;

int N;
vector<int> LeftVal, RightVal;

int binarySearch(int left, int right){
    int ans = -1;
    if(left+1 >= right) return -1;
    int mid = left + (right - left)/2;
    vector<int> trial = ask(mid);
    LeftVal[mid] = trial[0];
    RightVal[mid] = trial[1];
    if((trial[0] +trial[1]) == 0) return mid;
    int myRight = mid;
    int myLeft = mid;
    while((LeftVal[myLeft] + RightVal[myLeft]) < (LeftVal[left] + RightVal[left])){
        myLeft--;
        trial = ask(myLeft);
        LeftVal[myLeft] = trial[0];
        RightVal[myLeft] = trial[1];
        if((trial[0]+trial[1]) == 0) return myLeft;
    }
    while(((LeftVal[myRight] + RightVal[myRight]) < (LeftVal[left] + RightVal[left])) and (myRight < right)){
        myRight++;
        trial = ask(myRight);
        LeftVal[myRight] = trial[0];
        RightVal[myRight] = trial[1];
        if((trial[0]+trial[1]) == 0) return myRight;
    }
    if((LeftVal[myLeft] - LeftVal[left])  > 0) ans = max(ans, binarySearch(left, myLeft));
    if(myRight < right){
        if(right == N){
            if(RightVal[myRight] > 0) ans = max(ans, binarySearch(myRight, right));
        }
        else{
            if((RightVal[myRight]  - RightVal[right])> 0) ans = max(ans, binarySearch(myRight, right));
        }
    }    
    return ans;
}

int find_best(int n) {
    N = n;
    LeftVal = vector<int>(n, -1);
    RightVal = vector<int>(n, -1);
    vector<int> trial = ask(0);
    int lollipop = 0;
    LeftVal[0] = trial[0];
    RightVal[0] = trial[1];
    if((LeftVal[0] + RightVal[0]) == 0) return 0;
    for(int i = 1; i < min(n, 500); ++i){
        trial = ask(i);
        LeftVal[i] = trial[0];
        RightVal[i] = trial[1];
        if((LeftVal[i]+RightVal[i]) >= (LeftVal[lollipop] + RightVal[lollipop])) lollipop = i;
        if((LeftVal[i] + RightVal[i]) == 0) return i;
    }
    return binarySearch(lollipop, n);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1872 KB Output is correct
2 Correct 4 ms 1832 KB Output is correct
3 Correct 5 ms 1828 KB Output is correct
4 Correct 5 ms 1872 KB Output is correct
5 Correct 3 ms 1816 KB Output is correct
6 Correct 1 ms 1808 KB Output is correct
7 Correct 4 ms 1824 KB Output is correct
8 Correct 7 ms 1860 KB Output is correct
9 Correct 3 ms 1872 KB Output is correct
10 Correct 4 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1872 KB Output is correct
2 Correct 4 ms 1820 KB Output is correct
3 Correct 3 ms 1832 KB Output is correct
4 Correct 6 ms 1828 KB Output is correct
5 Correct 3 ms 1824 KB Output is correct
6 Correct 1 ms 1872 KB Output is correct
7 Correct 5 ms 1872 KB Output is correct
8 Correct 4 ms 1872 KB Output is correct
9 Correct 4 ms 1872 KB Output is correct
10 Correct 7 ms 1872 KB Output is correct
11 Correct 8 ms 1860 KB Output is correct
12 Correct 9 ms 1872 KB Output is correct
13 Correct 11 ms 1832 KB Output is correct
14 Correct 13 ms 336 KB Output is correct
15 Partially correct 21 ms 1884 KB Partially correct - number of queries: 5329
16 Partially correct 45 ms 1864 KB Partially correct - number of queries: 5618
17 Correct 5 ms 1872 KB Output is correct
18 Partially correct 53 ms 1828 KB Partially correct - number of queries: 5539
19 Correct 6 ms 1808 KB Output is correct
20 Correct 38 ms 976 KB Output is correct
21 Partially correct 47 ms 1860 KB Partially correct - number of queries: 5570
22 Correct 42 ms 1832 KB Output is correct
23 Correct 6 ms 1820 KB Output is correct
24 Correct 10 ms 1788 KB Output is correct
25 Partially correct 37 ms 1736 KB Partially correct - number of queries: 5148
26 Partially correct 50 ms 1820 KB Partially correct - number of queries: 5175
27 Correct 5 ms 1824 KB Output is correct
28 Partially correct 45 ms 1868 KB Partially correct - number of queries: 5136
29 Correct 18 ms 1876 KB Output is correct
30 Partially correct 54 ms 1816 KB Partially correct - number of queries: 5496
31 Correct 5 ms 1884 KB Output is correct
32 Correct 9 ms 1832 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Partially correct 46 ms 1864 KB Partially correct - number of queries: 5570
35 Correct 5 ms 1824 KB Output is correct
36 Partially correct 42 ms 1872 KB Partially correct - number of queries: 5515
37 Correct 9 ms 1828 KB Output is correct
38 Correct 6 ms 1872 KB Output is correct
39 Partially correct 36 ms 1872 KB Partially correct - number of queries: 5530
40 Correct 36 ms 1872 KB Output is correct
41 Partially correct 44 ms 1864 KB Partially correct - number of queries: 5588
42 Partially correct 40 ms 1860 KB Partially correct - number of queries: 5588
43 Partially correct 39 ms 1860 KB Partially correct - number of queries: 5411
44 Partially correct 48 ms 1864 KB Partially correct - number of queries: 5550
45 Partially correct 38 ms 1884 KB Partially correct - number of queries: 5174
46 Correct 5 ms 1828 KB Output is correct
47 Partially correct 40 ms 1832 KB Partially correct - number of queries: 5184
48 Partially correct 41 ms 1872 KB Partially correct - number of queries: 5594
49 Partially correct 50 ms 1856 KB Partially correct - number of queries: 5605
50 Partially correct 42 ms 1876 KB Partially correct - number of queries: 5557
51 Partially correct 35 ms 1736 KB Partially correct - number of queries: 5600
52 Partially correct 54 ms 1872 KB Partially correct - number of queries: 5528
53 Correct 7 ms 1828 KB Output is correct
54 Partially correct 30 ms 1944 KB Partially correct - number of queries: 5584
55 Correct 3 ms 1828 KB Output is correct
56 Partially correct 24 ms 1872 KB Partially correct - number of queries: 5551
57 Partially correct 54 ms 1872 KB Partially correct - number of queries: 5547
58 Partially correct 41 ms 1872 KB Partially correct - number of queries: 5581
59 Partially correct 39 ms 1824 KB Partially correct - number of queries: 5611
60 Partially correct 29 ms 1868 KB Partially correct - number of queries: 5502
61 Correct 5 ms 1872 KB Output is correct
62 Correct 6 ms 1736 KB Output is correct
63 Correct 3 ms 1828 KB Output is correct
64 Correct 8 ms 1832 KB Output is correct
65 Correct 5 ms 1792 KB Output is correct
66 Correct 5 ms 1808 KB Output is correct
67 Correct 7 ms 1824 KB Output is correct
68 Correct 5 ms 1828 KB Output is correct
69 Correct 7 ms 1832 KB Output is correct
70 Correct 5 ms 1872 KB Output is correct
71 Partially correct 44 ms 1872 KB Partially correct - number of queries: 6201
72 Correct 8 ms 1872 KB Output is correct
73 Partially correct 49 ms 1872 KB Partially correct - number of queries: 6124
74 Partially correct 36 ms 1872 KB Partially correct - number of queries: 6157
75 Correct 5 ms 2000 KB Output is correct
76 Partially correct 43 ms 1872 KB Partially correct - number of queries: 5409
77 Partially correct 23 ms 1832 KB Partially correct - number of queries: 5693
78 Correct 8 ms 1872 KB Output is correct
79 Correct 33 ms 1872 KB Output is correct
80 Partially correct 54 ms 1872 KB Partially correct - number of queries: 5651
81 Partially correct 51 ms 1872 KB Partially correct - number of queries: 5669
82 Partially correct 50 ms 1872 KB Partially correct - number of queries: 5593
83 Correct 3 ms 1872 KB Output is correct
84 Correct 42 ms 1872 KB Output is correct
85 Partially correct 50 ms 1872 KB Partially correct - number of queries: 5613
86 Correct 6 ms 1884 KB Output is correct
87 Correct 6 ms 1872 KB Output is correct
88 Correct 7 ms 1872 KB Output is correct
89 Correct 5 ms 1880 KB Output is correct
90 Correct 5 ms 1872 KB Output is correct
91 Correct 5 ms 1872 KB Output is correct
92 Correct 3 ms 1828 KB Output is correct
93 Correct 7 ms 1872 KB Output is correct
94 Correct 7 ms 1872 KB Output is correct
95 Correct 8 ms 1872 KB Output is correct
96 Correct 10 ms 1872 KB Output is correct
97 Correct 4 ms 1872 KB Output is correct