Submission #336052

#TimeUsernameProblemLanguageResultExecution timeMemory
336052aryan12쌀 창고 (IOI11_ricehub)C++17
100 / 100
15 ms1772 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int r, int l, int x[], long long b) { long long left = 0, right = 0, ans = 0; long long curCost = 0; while(left < r) { if(right >= r) break; long long OptimalField = (left + right) / 2; //cout << left << " " << right << " " << OptimalField << " " << curCost << endl; if(curCost + x[right] - x[OptimalField] <= b) { curCost += x[right] - x[OptimalField]; ans = max(ans, right - left + 1); right++; } else { curCost -= x[OptimalField] - x[left++]; } } return ans; } /* int main() { //cout << "Input the number of rice fields" << endl; int r; cin >> r; //cout << "Input the maaimum coordinate" << endl; int l; cin >> l; //cout << "Input r numbers, denoting the rice fields" << endl; int a[r]; for(int i = 0; i < r; i++) { cin >> a[i]; } //cout << "Input the budget" << endl; int b; cin >> b; cout << besthub(r, l, a, b) << endl; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...