답안 #500815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500815 2022-01-01T10:25:16 Z beaconmc 쌀 창고 (IOI11_ricehub) C++14
100 / 100
12 ms 1732 KB
//#include "ricehub.h"
#include <bits/stdc++.h>


typedef long long ll;
#define FOR(i, x, y) for(ll i=x; i<y; i++)

using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
  
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>


int besthub(int R, int L, int X[], ll B){
    ll lo = 0, hi = 0;
    ll ans = 1;
    ll curcost  = 0;
    while (hi<R){
        if (hi==lo) curcost += 0;
        else if ((hi-lo)%2==0) curcost += X[hi] - X[(hi-lo-1)/2+1 + lo];
        else curcost += X[hi] - X[(hi-lo-1)/2 + lo];
        if (curcost>B){
            if ((hi-lo)%2==0) curcost -= X[hi], curcost += X[lo];
            else curcost -= X[hi], curcost+= X[lo];
            lo ++;
        } else hi++;
        ans = max(ans, hi-lo);
    }
    return ans;
}

# 결과 실행 시간 메모리 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 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 304 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 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 308 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 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 304 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 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 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 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 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 304 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 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 308 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 304 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 10 ms 588 KB Output is correct
4 Correct 12 ms 1732 KB Output is correct
5 Correct 5 ms 772 KB Output is correct
6 Correct 5 ms 832 KB Output is correct
7 Correct 9 ms 1432 KB Output is correct
8 Correct 9 ms 1424 KB Output is correct
9 Correct 5 ms 740 KB Output is correct
10 Correct 4 ms 692 KB Output is correct
11 Correct 11 ms 1688 KB Output is correct
12 Correct 12 ms 1732 KB Output is correct
13 Correct 6 ms 852 KB Output is correct
14 Correct 6 ms 824 KB Output is correct
15 Correct 10 ms 1356 KB Output is correct
16 Correct 9 ms 1352 KB Output is correct
17 Correct 10 ms 1460 KB Output is correct
18 Correct 10 ms 1500 KB Output is correct
19 Correct 10 ms 1596 KB Output is correct
20 Correct 12 ms 1584 KB Output is correct