답안 #465410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465410 2021-08-16T00:25:44 Z pdstiago 쌀 창고 (IOI11_ricehub) C++14
100 / 100
27 ms 3296 KB
#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007
#define mxn 100005
#define mxm 105
#define f first
#define s second
#define pb push_back
#define es " "
#define endl '\n'
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
typedef pair<string, string> pii;
typedef pair<int, pii> pip;

int resp;
ll prefix[mxn], v[mxn];

ll testa(int i, int j){
    int med=(i+j)/2;
    ll sum=((prefix[j]-prefix[med])-v[med]*(j-med))+((med-i)*v[med]-(prefix[med-1]-prefix[i-1]));
    return sum;
}

int besthub(int n, int l, int x[], ll b){
    for(int i=1; i<=n; i++){
        v[i]=x[i-1];
        prefix[i]=prefix[i-1]+v[i];
    }
    for(int i=1; i<=n; i++){
        int ini=i, fim=n, meio;
        while(ini<=fim){
            meio=(ini+fim)/2;
            if(testa(i, meio)<=b){
                resp=max(resp, meio-i+1);
                ini=meio+1;
            }else{
                fim=meio-1;
            }
        }
    }
    return resp;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 288 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 436 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 588 KB Output is correct
2 Correct 4 ms 716 KB Output is correct
3 Correct 22 ms 3276 KB Output is correct
4 Correct 22 ms 3184 KB Output is correct
5 Correct 11 ms 1620 KB Output is correct
6 Correct 11 ms 1612 KB Output is correct
7 Correct 20 ms 3024 KB Output is correct
8 Correct 20 ms 2960 KB Output is correct
9 Correct 10 ms 1484 KB Output is correct
10 Correct 13 ms 1528 KB Output is correct
11 Correct 27 ms 3296 KB Output is correct
12 Correct 24 ms 3268 KB Output is correct
13 Correct 10 ms 1588 KB Output is correct
14 Correct 10 ms 1612 KB Output is correct
15 Correct 16 ms 2512 KB Output is correct
16 Correct 16 ms 2508 KB Output is correct
17 Correct 19 ms 2980 KB Output is correct
18 Correct 19 ms 2988 KB Output is correct
19 Correct 22 ms 3144 KB Output is correct
20 Correct 23 ms 3116 KB Output is correct