답안 #405360

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405360 2021-05-16T09:42:20 Z Andyvanh1 쌀 창고 (IOI11_ricehub) C++14
100 / 100
27 ms 2500 KB
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define vt vector
#define pb push_back
#define all(x) x.begin(),x.end()

typedef vt<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

ll prefsum[100005];

int besthub(int r, int l, int x[], ll b){
    prefsum[0] = 0;
    for(int i = 1; i <= r; i++){
        prefsum[i] = prefsum[i-1]+x[i-1];
    }
    int ans = 1;
    for(int i = 0; i < r; i++){
        int L = i;
        int R = r;
        while(L!=R) {
            int j = (L+R)>>1;

            int mid = (i + j) >> 1;
            ll n = (ll) x[mid] * (2 * mid - j - i + 1) - (prefsum[mid + 1] - prefsum[i]) +
                   (prefsum[j + 1] - prefsum[mid + 1]);
            if (n <= b) {
                L = j+1;
            }else{
                R = j;
            }
        }
        ans = max(ans,R-i);

    }
    return ans;


}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 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 204 KB Output is correct
8 Correct 1 ms 204 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 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 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 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 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 1 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 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 204 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 204 KB Output is correct
8 Correct 1 ms 204 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 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 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 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 2 ms 320 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 460 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
3 Correct 25 ms 1388 KB Output is correct
4 Correct 27 ms 1476 KB Output is correct
5 Correct 12 ms 844 KB Output is correct
6 Correct 12 ms 1228 KB Output is correct
7 Correct 24 ms 2216 KB Output is correct
8 Correct 24 ms 2124 KB Output is correct
9 Correct 12 ms 1128 KB Output is correct
10 Correct 12 ms 1100 KB Output is correct
11 Correct 27 ms 2500 KB Output is correct
12 Correct 26 ms 2468 KB Output is correct
13 Correct 12 ms 1284 KB Output is correct
14 Correct 12 ms 1228 KB Output is correct
15 Correct 24 ms 1868 KB Output is correct
16 Correct 19 ms 1920 KB Output is correct
17 Correct 23 ms 2244 KB Output is correct
18 Correct 23 ms 2276 KB Output is correct
19 Correct 24 ms 2380 KB Output is correct
20 Correct 26 ms 2388 KB Output is correct