이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
#include "ricehub.h"
const int N = (int)(1e6) + 5;
ll s[N];
ll ss[N];
ll get(int l,int m,int r)
{
return (ss[r] - ss[m]) - (r - m) * s[m] + (m - l) * s[m] - (ss[m - 1] - ss[l - 1]);
}
int besthub(int N, int L, int X[], ll B)
{
int n = N;
int m = L;
ll k = B;
int ans = 0;
for (int i = 0;i < n;++i)
s[i + 1] = X[i],ss[i + 1] = ss[i] + s[i + 1];
for (int i = 1;i <= n;++i)
{
int len = 0;
for (int t = 1 << 17;t;t /= 2)
if (get(max(1,i - len - t),i,min(n,i + len + t)) <= k)
len += t;
int L = max(1,i - len);
int R = min(n,i + len);
if (get(L,i,R) <= k)
ans = max(ans,R - L + 1);
if (L > 1 && get(L - 1,i,R) <= k)
ans = max(ans,R - L + 2);
if (R < n && get(L,i,R + 1) <= k)
ans = max(ans,R - L + 2);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:32:9: warning: unused variable 'm' [-Wunused-variable]
int m = L;
^
# | 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... |