답안 #1118421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1118421 2024-11-25T13:28:34 Z adaawf 커다란 상품 (IOI17_prize) C++17
20 / 100
87 ms 3264 KB
#include <iostream>
#include <vector>
using namespace std;
int a[200005], cc = 0, hh = 200000, dd[200005], c[200005][10];
void build(int n) {
    for (int j = 0; j <= 9; j++) {
        for (int i = 1; i <= n; i++) {
            c[i][j] = c[i - 1][j] + (a[i] <= j);
        }
    }
}
vector<int> ask(int i);
int find_best(int n) {
    vector<pair<int, pair<int, int>>> v;
    vector<int> t;
    int mi = 0;
    for (int i = 0; i <= 480; i++) {
        t = ask(i);
        if (t[0] + t[1] == 0) return i;
        mi = max(mi, t[0] + t[1]);
    }
    for (int i = 1; i <= n; i++) dd[i] = 0;
    int c = 0;
    for (int i = 1; i <= n; i += 200) {
        while (1) {
            if (i > n) break;
            t = ask(i);
            if (t[0] + t[1] == 0) return i;
            if (t[0] + t[1] == mi) {
                break;
            }
            c++;
            i++;
        }
        if (i <= n) {
            v.push_back({i, {t[1], c}});
            c = 0;
        }
    }
    v.push_back({n + 1, {0, c}});
    for (int i = 0; i < v.size() - 1; i++) {
        int h = v[i].second.first - v[i + 1].second.first;
        h -= v[i + 1].second.second;
        vector<int> va, vc, vv;
        for (int j = v[i].first; j < min(v[i].first + 200, n + 1); j++) {
            va.push_back(j);
        }
        for (int j = 0; j < h; j++) {
            int l = 0, r = va.size() - 1, res;
            while (1) {
                int mid = (l + r) / 2;
                res = va[mid];
                dd[va[mid]] = 1;
                t = ask(va[mid]);
                if (t[0] + t[1] == 0) return va[mid];
                if (t[0] + t[1] != mi) break;
                for (int w : vc) {
                    if (w <= va[mid]) t[1]++;
                }
                if (t[1] == v[i].second.first) {
                    l = mid + 1;
                }
                else r = mid - 1;
            }
            vc.push_back(res);
            vv.clear();
            for (int w : va) {
                if (dd[w] == 0) vv.push_back(w);
            }
            va = vv;
        }
    }
    return -1;
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 0; i < v.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2992 KB Output is correct
2 Correct 27 ms 2972 KB Output is correct
3 Correct 20 ms 2496 KB Output is correct
4 Correct 27 ms 2640 KB Output is correct
5 Correct 24 ms 2640 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 25 ms 2508 KB Output is correct
8 Correct 28 ms 2876 KB Output is correct
9 Correct 24 ms 2740 KB Output is correct
10 Correct 24 ms 2744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 2504 KB Output is correct
2 Correct 27 ms 2888 KB Output is correct
3 Correct 27 ms 2728 KB Output is correct
4 Correct 24 ms 2744 KB Output is correct
5 Correct 26 ms 2984 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 24 ms 2740 KB Output is correct
8 Correct 25 ms 3264 KB Output is correct
9 Correct 29 ms 2640 KB Output is correct
10 Correct 24 ms 2640 KB Output is correct
11 Correct 29 ms 3260 KB Output is correct
12 Correct 26 ms 2748 KB Output is correct
13 Correct 26 ms 2496 KB Output is correct
14 Correct 13 ms 2496 KB Output is correct
15 Correct 33 ms 2640 KB Output is correct
16 Correct 73 ms 2876 KB Output is correct
17 Correct 7 ms 336 KB Output is correct
18 Correct 73 ms 2640 KB Output is correct
19 Correct 7 ms 336 KB Output is correct
20 Correct 27 ms 2384 KB Output is correct
21 Correct 42 ms 2736 KB Output is correct
22 Correct 24 ms 2748 KB Output is correct
23 Correct 25 ms 2896 KB Output is correct
24 Correct 21 ms 2732 KB Output is correct
25 Correct 54 ms 2652 KB Output is correct
26 Correct 57 ms 2640 KB Output is correct
27 Correct 25 ms 2640 KB Output is correct
28 Correct 83 ms 2492 KB Output is correct
29 Correct 64 ms 2728 KB Output is correct
30 Correct 87 ms 2896 KB Output is correct
31 Correct 7 ms 336 KB Output is correct
32 Correct 26 ms 2640 KB Output is correct
33 Correct 2 ms 336 KB Output is correct
34 Correct 43 ms 2748 KB Output is correct
35 Correct 27 ms 2492 KB Output is correct
36 Correct 37 ms 2728 KB Output is correct
37 Correct 28 ms 2728 KB Output is correct
38 Correct 26 ms 2888 KB Output is correct
39 Correct 50 ms 2976 KB Output is correct
40 Correct 73 ms 2740 KB Output is correct
41 Correct 61 ms 2736 KB Output is correct
42 Correct 59 ms 2888 KB Output is correct
43 Correct 45 ms 2976 KB Output is correct
44 Correct 42 ms 2724 KB Output is correct
45 Correct 38 ms 2724 KB Output is correct
46 Correct 8 ms 444 KB Output is correct
47 Correct 46 ms 2736 KB Output is correct
48 Correct 57 ms 2636 KB Output is correct
49 Correct 27 ms 2732 KB Output is correct
50 Correct 66 ms 2896 KB Output is correct
51 Correct 15 ms 2724 KB Output is correct
52 Correct 24 ms 2720 KB Output is correct
53 Correct 23 ms 2736 KB Output is correct
54 Correct 42 ms 2736 KB Output is correct
55 Correct 7 ms 336 KB Output is correct
56 Correct 71 ms 2736 KB Output is correct
57 Correct 65 ms 2736 KB Output is correct
58 Correct 72 ms 2888 KB Output is correct
59 Correct 51 ms 2640 KB Output is correct
60 Correct 53 ms 2724 KB Output is correct
61 Correct 25 ms 2740 KB Output is correct
62 Correct 25 ms 2640 KB Output is correct
63 Correct 28 ms 2480 KB Output is correct
64 Correct 24 ms 2976 KB Output is correct
65 Correct 20 ms 2732 KB Output is correct
66 Correct 36 ms 2640 KB Output is correct
67 Incorrect 29 ms 2640 KB Integer 200000 violates the range [0, 199999]
68 Halted 0 ms 0 KB -