# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1118401 | adaawf | The Big Prize (IOI17_prize) | C++17 | 181 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
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]);
}
int c = 0;
for (int i = 1; i <= 20000; i += 10) {
c = 0;
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}});
}
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;
if (h >= 2) {
for (int j = v[i].first + 1; j < v[i].first + 10; j++) {
t = ask(i);
if (t[0] + t[1] == 0) return j;
}
}
else if (h == 1) {
int l = v[i].first + 1, r = v[i].first + 9, res;
while (l <= r) {
int mid = (l + r) / 2;
t = ask(mid);
if (t[0] + t[1] == 0) return mid;
if (t[0] + t[1] != mi) break;
if (t[1] == v[i].second.first) {
res = mid;
l = mid + 1;
}
else r = mid - 1;
}
}
}
return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |