답안 #1079259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079259 2024-08-28T12:22:42 Z speedcode 커다란 상품 (IOI17_prize) C++17
20 / 100
1000 ms 11444 KB
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;

vector<int> dp[200000];

vector<int> myAsk(int n) {
    if(dp[n][0] == -1) dp[n] = ask(n);
    return dp[n];
}

int find_best(int n) {
    for(int i = 0; i < n; i++) {
        dp[i] = {-1, -1};
    }
    //binary search the first element each time
    int hi = 0;
    int last = 0;
    auto a = myAsk(0);
    if (a[0] + a[1] == 0) return 0;
    int datMax = a[0] + a[1];
    int thatAreMax = 1;
    while (true) {
        int i1 = last;
        int i2 = n - 1;
        while (i1 != i2) {
            int middle = ceil(((double)i1 + i2) / 2.0);
            auto a = myAsk(middle);
            if (a[0] + a[1] == 0) return middle;
            if(a[0] + a[1] > datMax) {
                datMax = a[0] + a[1];
                hi += thatAreMax;
                thatAreMax = 0;
            }
            if(i2-i1 > 1) {
                if (a[0] - hi == 0) {
                    if(a[0] + a[1] < datMax) {
                        i1 = middle;
                        i2 = middle;
                    }else i1 = middle+1;
                }else {
                    i2 = middle;
                }
            }else {
                auto b = myAsk(i1);
                if(b[0]+b[1] < a[0]+a[1]) {
                    i2 = i1;
                }else i1 = i2;
            }
        }

        auto a = myAsk(i1);
        if (a[0] + a[1] == 0) return i1;
        last = i1;
        if(a[0] + a[1] > datMax) {
            datMax = a[0] + a[1];
            hi += thatAreMax;
            thatAreMax = 0;
        }
        if (a[0] + a[1] < datMax) hi++;
        else thatAreMax++;

    }

}


# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 11272 KB Output is correct
2 Correct 10 ms 11352 KB Output is correct
3 Correct 9 ms 11352 KB Output is correct
4 Correct 11 ms 11320 KB Output is correct
5 Correct 9 ms 11352 KB Output is correct
6 Correct 11 ms 11268 KB Output is correct
7 Correct 15 ms 11352 KB Output is correct
8 Correct 10 ms 11272 KB Output is correct
9 Correct 13 ms 11352 KB Output is correct
10 Correct 9 ms 11336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 11352 KB Output is correct
2 Correct 11 ms 11352 KB Output is correct
3 Correct 8 ms 11348 KB Output is correct
4 Correct 8 ms 11352 KB Output is correct
5 Correct 8 ms 11352 KB Output is correct
6 Correct 9 ms 11352 KB Output is correct
7 Correct 8 ms 11352 KB Output is correct
8 Correct 12 ms 11348 KB Output is correct
9 Correct 10 ms 11352 KB Output is correct
10 Correct 10 ms 11292 KB Output is correct
11 Correct 10 ms 11352 KB Output is correct
12 Correct 9 ms 11352 KB Output is correct
13 Correct 12 ms 11352 KB Output is correct
14 Correct 7 ms 5720 KB Output is correct
15 Correct 18 ms 11352 KB Output is correct
16 Partially correct 52 ms 11352 KB Partially correct - number of queries: 6561
17 Correct 11 ms 11352 KB Output is correct
18 Partially correct 63 ms 11352 KB Partially correct - number of queries: 7687
19 Correct 9 ms 11352 KB Output is correct
20 Correct 21 ms 8024 KB Output is correct
21 Correct 25 ms 11352 KB Output is correct
22 Correct 13 ms 11352 KB Output is correct
23 Correct 12 ms 11352 KB Output is correct
24 Correct 8 ms 11352 KB Output is correct
25 Correct 29 ms 11352 KB Output is correct
26 Correct 29 ms 11168 KB Output is correct
27 Correct 8 ms 11352 KB Output is correct
28 Partially correct 51 ms 11352 KB Partially correct - number of queries: 7264
29 Partially correct 40 ms 11348 KB Partially correct - number of queries: 5522
30 Partially correct 63 ms 11352 KB Partially correct - number of queries: 7617
31 Correct 8 ms 11352 KB Output is correct
32 Correct 10 ms 11268 KB Output is correct
33 Correct 2 ms 4952 KB Output is correct
34 Correct 28 ms 11352 KB Output is correct
35 Correct 9 ms 11352 KB Output is correct
36 Correct 18 ms 11264 KB Output is correct
37 Correct 9 ms 11352 KB Output is correct
38 Correct 14 ms 11392 KB Output is correct
39 Correct 26 ms 11352 KB Output is correct
40 Partially correct 51 ms 11352 KB Partially correct - number of queries: 6519
41 Correct 25 ms 11352 KB Output is correct
42 Correct 36 ms 11352 KB Output is correct
43 Correct 36 ms 11352 KB Output is correct
44 Correct 22 ms 11352 KB Output is correct
45 Correct 22 ms 11352 KB Output is correct
46 Correct 9 ms 11352 KB Output is correct
47 Correct 34 ms 11352 KB Output is correct
48 Partially correct 50 ms 11444 KB Partially correct - number of queries: 5716
49 Correct 10 ms 11352 KB Output is correct
50 Partially correct 48 ms 11356 KB Partially correct - number of queries: 7654
51 Correct 25 ms 11352 KB Output is correct
52 Correct 8 ms 11352 KB Output is correct
53 Correct 8 ms 11352 KB Output is correct
54 Correct 33 ms 11352 KB Output is correct
55 Correct 8 ms 11352 KB Output is correct
56 Partially correct 53 ms 11252 KB Partially correct - number of queries: 7679
57 Partially correct 45 ms 11352 KB Partially correct - number of queries: 5626
58 Partially correct 40 ms 11352 KB Partially correct - number of queries: 5672
59 Correct 23 ms 11352 KB Output is correct
60 Correct 38 ms 11352 KB Output is correct
61 Correct 11 ms 11252 KB Output is correct
62 Correct 8 ms 11352 KB Output is correct
63 Correct 10 ms 11352 KB Output is correct
64 Correct 8 ms 11352 KB Output is correct
65 Correct 10 ms 11352 KB Output is correct
66 Correct 10 ms 11352 KB Output is correct
67 Correct 13 ms 11352 KB Output is correct
68 Correct 12 ms 11396 KB Output is correct
69 Correct 9 ms 11352 KB Output is correct
70 Correct 10 ms 11352 KB Output is correct
71 Partially correct 47 ms 11308 KB Partially correct - number of queries: 8086
72 Correct 13 ms 11352 KB Output is correct
73 Partially correct 49 ms 11352 KB Partially correct - number of queries: 7979
74 Partially correct 50 ms 11352 KB Partially correct - number of queries: 8002
75 Correct 10 ms 11352 KB Output is correct
76 Partially correct 50 ms 11352 KB Partially correct - number of queries: 6955
77 Partially correct 37 ms 11352 KB Partially correct - number of queries: 7830
78 Correct 11 ms 11352 KB Output is correct
79 Correct 27 ms 11352 KB Output is correct
80 Partially correct 52 ms 11348 KB Partially correct - number of queries: 7782
81 Partially correct 47 ms 11352 KB Partially correct - number of queries: 7783
82 Partially correct 47 ms 11352 KB Partially correct - number of queries: 7730
83 Correct 11 ms 11352 KB Output is correct
84 Partially correct 45 ms 11352 KB Partially correct - number of queries: 6394
85 Partially correct 66 ms 11352 KB Partially correct - number of queries: 7756
86 Execution timed out 3063 ms 11352 KB Time limit exceeded
87 Halted 0 ms 0 KB -