Submission #937826

# Submission time Handle Problem Language Result Execution time Memory
937826 2024-03-04T14:54:57 Z Alcabel The Big Prize (IOI17_prize) C++17
Compilation error
0 ms 0 KB
const int need = 473;

int find_best(int n) {
    int mxcnt = 0;
    vector<int> res;
    int nonmax = 0;
    for (int i = 0; i < min(n, need); ++i) {
        res = ask(i);
        if (res[0] + res[1] == 0) {
            return i;
        }
        if (res[0] + res[1] > mxcnt) {
            mxcnt = res[0] + res[1];
            nonmax = i;
        } else if (res[0] + res[1] < mxcnt) {
            ++nonmax;
        }
    }
    int last = need - 1;
    while (true) {
        int left = last, right = n;
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            res = ask(mid);
            if (res[0] + res[1] == 0) {
                return mid;
            }
            if (res[0] + res[1] < mxcnt) {
                right = mid;
            } else if (res[0] == nonmax) {
                left = mid;
            } else {
                right = mid;
            }
        }
        assert(right != n);
        last = right;
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> res;
      |     ^~~~~~
prize.cpp:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> res;
      |            ^~~
prize.cpp:7:25: error: 'min' was not declared in this scope
    7 |     for (int i = 0; i < min(n, need); ++i) {
      |                         ^~~
prize.cpp:8:9: error: 'res' was not declared in this scope
    8 |         res = ask(i);
      |         ^~~
prize.cpp:8:15: error: 'ask' was not declared in this scope
    8 |         res = ask(i);
      |               ^~~
prize.cpp:24:13: error: 'res' was not declared in this scope
   24 |             res = ask(mid);
      |             ^~~
prize.cpp:24:19: error: 'ask' was not declared in this scope
   24 |             res = ask(mid);
      |                   ^~~
prize.cpp:36:9: error: 'assert' was not declared in this scope
   36 |         assert(right != n);
      |         ^~~~~~
prize.cpp:1:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
  +++ |+#include <cassert>
    1 | const int need = 473;