Submission #261632

#TimeUsernameProblemLanguageResultExecution timeMemory
261632s_avila_gRice Hub (IOI11_ricehub)C++14
17 / 100
317 ms1404 KiB
#include <bits/stdc++.h> using namespace std; #include "ricehub.h" typedef long long ll; priority_queue<int,vector<int>, greater<int> > pq; int besthub(int R, int L, int X[],ll B){ ll n = R, ans = -1, act, sum; ll low = 1, high = L; while(low < high){ ll mid = (low + high) / 2; ll midleft = (low + mid) / 2, midright = (mid + high) / 2; ll distsleft = 0, distsright = 0; for(ll j = 0; j < n; j++){ distsleft += abs(midleft - X[j]); distsright += abs(midright - X[j]); } for(ll j = 0; j < n; j++){ pq.push(abs(mid - X[j])); } sum = act = 0; while(!pq.empty()){ if(sum + pq.top() > B){ pq.pop(); continue; }else{ sum += pq.top(); act++; } pq.pop(); } ans = max(ans,act); if(distsleft < distsright){ high = mid; }else{ low = mid+1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...