Submission #527490

#TimeUsernameProblemLanguageResultExecution timeMemory
527490stefantagaThe Big Prize (IOI17_prize)C++14
98.23 / 100
69 ms5236 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; vector <int> sal[200005]; int find_best(int n) { int Max=0,i; srand(time(NULL)); for (int i = 0; i < n; ++ i ) { int left = i+1, right = min (n-1,i+1018); vector <int> val; if (sal[i].size()!=0) { val=sal[i]; } else { val=ask(i); sal[i]=val; } Max=max(Max,val[0]+val[1]); int poz_right = i; if (val[0] + val[1] == 0) { return i; } if (Max!=val[0]+val[1]) { continue; } while (left <= right) { int mid = (left + right) / 2; vector <int> cnt; if (sal[mid].size()) { cnt=sal[mid]; } else { cnt=ask(mid); sal[mid]=cnt; } if (cnt[0] + cnt[1] == 0) { return mid; } bool Type = (cnt[0] + cnt[1] == val[0] + val[1]); if (Type) { int cate_sunt = cnt[0] - val[0]; if (cate_sunt == 0) { poz_right = mid; left = mid + 1; } else right = mid - 1; } else { right = mid - 1; } } i = poz_right; } return n-1; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:6:15: warning: unused variable 'i' [-Wunused-variable]
    6 |     int Max=0,i;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...