이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |