이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int besthub (int r, int l, int x[], long long b) {
int ans = 1, right = 0, cur = 1;
ll tot = 0;
deque<int> dq;
dq.pb(x[0]);
rep (i,1,r-1) {
while (right<r-1) {
ll newy = tot;
dq.pb(x[right+1]);
int nmid = dq[((int)dq.size()-1)/2];
newy += dq.back()-nmid;
if (newy<=b) {
tot = newy;
ans = max(ans, ++cur);
right++;
}
else {
dq.pop_back();
break;
}
}
tot -= dq[((int)dq.size()-1)/2]-dq.front();
if ((int)dq.size()%2==0) tot -= dq[(int)dq.size()/2]-dq[((int)dq.size()-1)/2];
dq.pop_front();
cur--;
}
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... |