# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1109865 | santi3223 | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define vs vector<string>
#define vb vector<bool>
#define ull unsigned long long
#define pll pair<ll, ll>
#define pb push_back
#define fi first
#define se second
#define ff(i, p, x) for (ll i = p; i < x; i++)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ed "\n"
#define IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll MOD = 1e9+7;
ll besthub(ll r, ll l, vl x, ll b){
vl psum(r+1, 0);
ff(i, 1, r){
psum[i] = psum[i-1]+x[i];
}
ll ri = 0, c = 0;
ff(le, 0, r){
while(ri < r){
ll mid = le + (ri-le)/2;
if(le % 2 == ri % 2){
mid++;
}
ll q = 0;
if((le+ri+1) % 2 != 0){
q -= x[mid];
}
q -= psum[mid]-psum[le];
q += psum[ri+1] - psum[mid];
if(q > b){
break;
}
ri++;
}
if(c < ri-le){
c = ri-le;
}
if(ri == r){
break;
}
}
return c;
}
/*
int main(){
IO
ll r, l, b;
cin >> r >> l >> b;
vl x(r);
ff(i, 0, r){
cin >> x[i];
}
cout << besthub(r, l, x, b);
return 0;
}
*/