이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int besthub(int R, int L, int X[], ll B){
queue<ll> l, r;
for (int i=0; i<R; i++) r.push(X[i]);
int bsf = 0, curl = 0, curr = 0, i = 0;
ll k = 0;
while (true){
while (!l.empty() && !r.empty() && curl && (r.front()-X[i]) < (X[i]-l.front())){
//cout << "b\n";
k += r.front()+l.front()-2ll* (ll) X[i];
l.pop();
l.push(r.front());
r.pop();
curl--;
curr++;
}
//cout << k << " " << r.front() << " " << X[i] << " " << B << "\n";
while (!r.empty() && ((k+(r.front()-(ll) X[i])) <= B)){
//cout << "a\n";
k += r.front()- (ll) X[i];
l.push(r.front());
r.pop();
curr++;
}
if (k <= B) bsf = max(bsf, curl+curr);
//cout << i << " " << curl << " " << curr << " " << k << " " << bsf << "\n";
i++;
if (i == R) break;
curl++; curr--;
if (X[i] != X[i-1]) k += (ll) (curl-curr) * (ll) (X[i]-X[i-1]);
}
return bsf;
}
# | 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... |