Submission #1075914

#TimeUsernameProblemLanguageResultExecution timeMemory
1075914mdn2002The Big Prize (IOI17_prize)C++14
94.61 / 100
41 ms1368 KiB
#include "prize.h" #include<bits/stdc++.h> using namespace std; map<int, vector<int>> mp; vector<int> askk (int x) { if (mp.count(x) == 0) return mp[x] = ask(x); return mp[x]; } int find_best(int n) { int mx = 0, lim = 500; for (int i = 0; i < min(n, lim); i ++) { vector<int> a = askk(i); mx = max(mx, a[0] + a[1]); if (a[0] + a[1] == 0) return i; } int xxx = 500; for (int i = 0; i < n; i ++) { vector<int> a = askk(i); if (a[0] + a[1] == mx) { if (i + 500 < n) { vector<int> c = askk(i + 500); if (a[1] == c[1]) { i += 500; continue; } } int l = 0, r = 500; while (l < r) { int mid = (l + r) / 2; if (i + mid >= n) r = mid; else { vector<int> b = askk(i + mid); if (a[1] == b[1]) l = mid + 1; else r = mid; } } i += l - 1; } else if (a[0] + a[1] == 0) return i; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:17:6: warning: unused variable 'xxx' [-Wunused-variable]
   17 |  int xxx = 500;
      |      ^~~
prize.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...