답안 #1118416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1118416 2024-11-25T13:17:59 Z adaawf 커다란 상품 (IOI17_prize) C++17
0 / 100
26 ms 1620 KB
#include <iostream>
#include <vector>
using namespace std;
int a[200005], cc = 0, hh = 200000, dd[200005];
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 = 1; 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, vb, 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;
            vb.clear();
            while (1) {
                int mid = (l + r) / 2;
                vb.push_back(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(vb.back());
            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:34: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]
   34 |     for (int i = 0; i < v.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1472 KB Output is correct
2 Correct 21 ms 1464 KB Output is correct
3 Correct 25 ms 1244 KB Output is correct
4 Correct 26 ms 1484 KB Output is correct
5 Correct 23 ms 1620 KB Output is correct
6 Incorrect 19 ms 1360 KB Integer -1 violates the range [0, 199999]
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1104 KB Output is correct
2 Correct 21 ms 1236 KB Output is correct
3 Correct 20 ms 1352 KB Output is correct
4 Correct 24 ms 1116 KB Output is correct
5 Correct 24 ms 1464 KB Output is correct
6 Incorrect 23 ms 1236 KB Integer -1 violates the range [0, 199999]
7 Halted 0 ms 0 KB -