Submission #1079308

#TimeUsernameProblemLanguageResultExecution timeMemory
1079308speedcodeThe Big Prize (IOI17_prize)C++17
0 / 100
13 ms11352 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; vector<int> dp[200000]; vector<int> myAsk(int n) { if (dp[n][0] == -1) dp[n] = ask(n); return dp[n]; } int find_best(int n) { for (int i = 0; i < n; i++) { dp[i] = {-1, -1}; } int maxi = 0; for (int i = 0; i < min(450, n); i++) { maxi = max(maxi, myAsk(i)[0] + myAsk(i)[1]); } int last = 0; auto a = myAsk(0); if (a[0] + a[1] == 0) return 0; int y = n; while (y--) { cout << last << endl; int i1 = last + 1; int i2 = n - 1; if (myAsk(i1)[0] + myAsk(i1)[1] == maxi) { last = i1; continue; } while (i1 != i2) { int middle = (i1 + i2) / 2; auto a = myAsk(middle); if (a[0] + a[1] == 0) return middle; if(middle == i1) { i1 = i2; }else { auto b = myAsk(i1); if(a[0]-b[0] > 0) { i2 = middle-1; }else { i1 = middle; } } } auto a = myAsk(i1); if (a[0] + a[1] == 0) return i1; last = i1; } }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:23:21: warning: control reaches end of non-void function [-Wreturn-type]
   23 |     auto a = myAsk(0);
      |                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...