Submission #485236

#TimeUsernameProblemLanguageResultExecution timeMemory
485236chungdinhRice Hub (IOI11_ricehub)C++17
68 / 100
1090 ms1736 KiB
#include <cstdio> #include <string> #include <queue> #include <iostream> using namespace std; #define endl "\n" #define cntbit(x) __builtin_popcount(x) #define on(b, x) (b & (1 << x)) #define all(x) x.begin(), x.end() #define gcd __gcd #define ll long long #define ii pair<int, int> #define cost(l, r) a[r] - a[l] const int N = 3e3 + 5; const ll MOD = 998244353; const int iINF = 1e9; const ll INF = 1e18; int n, l; ll b; int a[N]; int besthub(int n, int l, int a[], ll b) { int res = 0; for (int i = 0; i < n; i++) { int l = i - 1, r = i + 1; int subres = 0; ll left = b; while (l >= 0 || r <= n - 1) { if (l < 0) { if (cost(i, r) > left) break; subres++; left -= cost(i, r); r++; } else if (r > n - 1) { if (cost(l, i) > left) break; subres++; left -= cost(l, i); l--; } else { ll tt = min(cost(l, i), cost(i, r)); if (tt > left) break; if (cost(l, i) < cost(i, r)) { left -= cost(l, i); l--; } else { left -= cost(i, r); r++; } subres++; } } res = max(res, subres + 1); } return res; } /* int main() { #ifdef CHUNGDINH freopen("main.inp", "r", stdin); #endif scanf("%d%lld%lld",&n,&l,&b); for (int i = 0; i < n; i++) scanf("%lld", a + i); printf("%d", besthub(n, l, a, b)); }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...