# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
418382 | ismoilov | 쌀 창고 (IOI11_ricehub) | C++14 | 16 ms | 2164 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
deque <int> fir, sec;
ll sum_fir, sum_sec;
ll check(){
int ans;
if(sec.size() == fir.size())
ans = sec.front();
else
ans = fir.back();
ll c = sum_sec - sum_fir;
c += (ll) ans * fir.size();
c -= (ll) ans * sec.size();
return c;
}
int besthub(int r, int l, int X[], ll b){
int ans = 0;
fp(i,0,r){
sec.push_back(X[i]);
sum_sec += X[i];
if(fir.size() < sec.size()){
sum_sec -= sec.front();
sum_fir += sec.front();
fir.push_back(sec.front());
sec.pop_front();
}
while(b < check()){
if(fir.empty()){
sum_sec -= sec.back();
sec.pop_back();
}
else{
sum_fir -= fir.front();
fir.pop_front();
}
if(fir.size() < sec.size()){
sum_sec -= sec.front();
sum_fir += sec.front();
fir.push_back(sec.front());
sec.pop_front();
}
}
ans = max(ans, (int) fir.size() + (int) sec.size());
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |