Submission #228396

#TimeUsernameProblemLanguageResultExecution timeMemory
228396tushar_2658Rice Hub (IOI11_ricehub)C++14
0 / 100
97 ms640 KiB
#include "ricehub.h" #include "bits/stdc++.h" using namespace std; const int maxn = 100005; using ll = long long; int a[maxn]; ll lim; vector<ll> p; int n; int besthub(int R, int L, int X[], long long B) { n = R; lim = B; p.resize(R); for(int i = 0; i < R; ++i){ a[i] = X[i]; } sort(a, a + R); for(int i = 0; i < R; ++i){ if(i == 0){ p[i] = a[i]; }else { p[i] = p[i - 1] + a[i]; } } int ans = 0; for(int i = 0; i < n; ++i){ ll mid = a[i]; int l = i, r = i; ll left = B; int done = 0; while(left > 0 && r < n && l >= 0){ ll nxt_l = LLONG_MAX; if(l > 0){ nxt_l = a[l] - a[l - 1]; } ll nxt_r = LLONG_MAX; if(r < n - 1){ nxt_r = a[r + 1] - a[r]; } if(nxt_l < nxt_r){ done++; left -= nxt_l; --l; }else { done++; left -= nxt_r; ++r; } } ans = max(ans, done); } return ans; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:31:7: warning: unused variable 'mid' [-Wunused-variable]
    ll mid = a[i];
       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...