Submission #577176

#TimeUsernameProblemLanguageResultExecution timeMemory
577176Theo830The Big Prize (IOI17_prize)C++17
20 / 100
75 ms336 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const int MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define ull unsigned int #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "prize.h" ll solve(ll l,ll r){ if(l > r){ return -1; } ll mid = (l+r)/2; vector<int>res = ask(mid); if(res[0] == 0 && res[1] == 0){ return mid; } if(l == r){ return -1; } ll ans; if(res[0] > res[1]){ ans = solve(l,mid); if(ans == -1){ ans = solve(mid+1,r); } } else{ ans = solve(mid+1,r); if(ans == -1){ ans = solve(l,mid); } } return ans; } int find_best(int n){ return solve(0,n-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...