답안 #577496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577496 2022-06-14T21:56:49 Z jeroenodb 쌀 창고 (IOI11_ricehub) C++14
0 / 100
3 ms 692 KB
#include "ricehub.h"
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;

int besthub(int R, int L, int X[], long long B) {
    vector<ll> p(R+1);
    for(int i=0;i<R;++i) {
        p[i+1]=p[i]+X[i];
    }
    int ans=0;
    for(int i=0,j=0;i<R;++i) {
        auto cost = [&](int jj) {
            int m = i+(jj-i)/2, m2 = jj- (jj-i)/2;
            return (p[jj+1]-p[m])-(p[m2+1]-p[i]);
        };
        while(j<R-1 and cost(j+1)<=B) {
            ++j;
        }
        ans = max(ans,j-i+1);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 216 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 640 KB Output is correct
2 Incorrect 3 ms 692 KB Output isn't correct
3 Halted 0 ms 0 KB -