Submission #417766

#TimeUsernameProblemLanguageResultExecution timeMemory
417766Mohammed_AtalahRice Hub (IOI11_ricehub)C++17
68 / 100
16 ms1660 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; int total = 0; int rice = 1; while (right < mx && left < mx) { if (X[right] - X[left] > B) { left++; if (left < mx) { int mid = left + ((right - left) / 2); total -= X[mid] - X[left - 1]; rice--; } } if (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...