이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
// R toplam pirinc tarlasi sayisi
// L yolun uzunlugu
// X[] pirinc tarlalarinin kordinatlari
// B harciyabilecegin maksimum para
// optimal cozum her zaman bir tarlanin uzerinde
{
int ans=0;
for(int i=0;i<R;i++){
int count=1;long long cost=0;
int l=i-1,r=i+1;
while(X[i]==X[i+1]){
count++;
i++;
r++;
}
while(cost <= B ){
int ll=INT_MAX,rr=INT_MAX;
if(0<=l and cost+(X[i]-X[l])<=B)ll=(X[i]-X[l]);
if(r<R and cost+(X[r]-X[i])<=B)rr=(X[r]-X[i]);
if(ll<=rr and ll!=INT_MAX){
count++;
cost+=ll;
l--;
}
else if(rr<ll and rr!=INT_MAX){
count++;
cost+=rr;
r++;
}
else break;
}
ans=max(ans,count);
}
return ans;
}
| # | 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... |