Submission #417808

#TimeUsernameProblemLanguageResultExecution timeMemory
417808Mohammed_AtalahRice Hub (IOI11_ricehub)C++17
100 / 100
15 ms1752 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { int left = 0; int right = 0; int mx = R; int res = 0; long long total = 0; int rice = 1; while (right < mx && left < mx) { if (X[right] - X[left] > B || total > B) { left++; if (left < mx) { int mid = left + ((right - left) / 2); total -= X[mid] - X[left - 1]; rice--; } } else { right++; if (rice > res) { res = rice; } if (right < mx) { int mid = left + ((right - left) / 2); total += X[right] - X[mid]; rice++; } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...