이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e5+7;
ll sum[LIM], T[LIM];
ll Q(int l, int r) {
return sum[r]-(l?sum[l-1]:0);
}
int besthub(int n, int m, int P[], long long b) {
rep(i, n) {
if(i) sum[i]=sum[i-1];
T[i]=P[i];
sum[i]+=T[i];
}
ll ans=1;
rep(i, n) {
ll p=0, k=min(i, n-i-1);
while(p<k) {
ll sr=(p+k+1)/2;
if(Q(i+1, i+sr)-Q(i-sr, i-1)<=b) p=sr; else k=sr-1;
}
ans=max(ans, 2*p+1);
}
for(int i=1; i<n; ++i) {
ll p=0, k=min(i-1, n-i-1);
while(p<k) {
ll sr=(p+k+1)/2;
if(Q(i+1, i+sr)-Q(i-sr-1, i-1)+T[i]<=b) p=sr; else k=sr-1;
}
if(T[i]-T[i-1]<=b) ans=max(ans, 2*p+2);
}
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... |