# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1013372 | 2024-07-03T13:03:52 Z | NintsiChkhaidze | The Big Prize (IOI17_prize) | C++17 | 45 ms | 5732 KB |
#include <bits/stdc++.h> #define pb push_back #include "prize.h" using namespace std; bool fix[200003]; int Q; vector <int> dp[200003]; vector <int> askk(int x){ if (dp[x].size()) return dp[x]; ++Q; // if (Q > 10000) assert(0); return dp[x] = ask(x); } int find_best(int n){ int block = 500,mx = -1; vector <int> opt; for (int i = 0; i < min(n,block); i++){ vector <int> vec = askk(i); int sum = vec[0] + vec[1]; if (sum == 0) return i; if (sum > mx){ mx = sum; opt = vec; } } for (int i = 0; i < n; i++){ int l = i, r = n - 1,res = -1; while (l <= r){ int mid = (l + r)/2; vector <int> vec = askk(mid); if (vec[0] + vec[1] == 0) return mid; if (vec != opt){ r = mid - 1; }else{ res = mid; l = mid + 1; } } if (res == -1) break; int id = res; l = res + 1; r = n - 1; while (l <= r){ int mid = (l + r)/2; vector <int> vec = askk(mid); if (vec[0] + vec[1] == 0) return mid; if (vec != opt){ r = mid - 1; }else{ res = mid; l = mid + 1; } } for (int j = id; j <= res; j++) fix[j] = 1; i = res; } for (int i = 0; i < n; i++){ if (!fix[i]){ vector <int> vec = askk(i); if (vec[0] + vec[1] == 0) return i; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4952 KB | Output is correct |
2 | Correct | 3 ms | 4952 KB | Output is correct |
3 | Correct | 2 ms | 4952 KB | Output is correct |
4 | Correct | 3 ms | 5152 KB | Output is correct |
5 | Correct | 3 ms | 4952 KB | Output is correct |
6 | Correct | 1 ms | 4952 KB | Output is correct |
7 | Correct | 5 ms | 4952 KB | Output is correct |
8 | Correct | 3 ms | 4952 KB | Output is correct |
9 | Correct | 3 ms | 4952 KB | Output is correct |
10 | Correct | 4 ms | 5208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4952 KB | Output is correct |
2 | Correct | 4 ms | 4952 KB | Output is correct |
3 | Correct | 2 ms | 5148 KB | Output is correct |
4 | Correct | 3 ms | 4952 KB | Output is correct |
5 | Correct | 3 ms | 4952 KB | Output is correct |
6 | Correct | 1 ms | 4952 KB | Output is correct |
7 | Correct | 4 ms | 5152 KB | Output is correct |
8 | Correct | 4 ms | 5216 KB | Output is correct |
9 | Correct | 3 ms | 4952 KB | Output is correct |
10 | Correct | 5 ms | 5148 KB | Output is correct |
11 | Incorrect | 45 ms | 5732 KB | Incorrect |
12 | Halted | 0 ms | 0 KB | - |