답안 #421092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
421092 2021-06-08T18:02:12 Z OttoTheDino 쌀 창고 (IOI11_ricehub) C++17
100 / 100
19 ms 2116 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

#define rep(i,s,e)                          for (int i = s; i <= e; ++i)
#define rrep(i,s,e)                         for (int i = s; i >= e; --i)
#define pb                                  push_back
#define pf                                  push_front
#define fi                                  first
#define se                                  second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int besthub (int r, int l, int x[], long long b) {
    int ans = 1, right = 0, cur = 1;
    ll tot = 0;
    deque<int> dq;
    dq.pb(x[0]);
    rep (i,1,r-1) {
        while (right<r-1) {
            ll newy = tot;
            dq.pb(x[right+1]);
            int nmid = dq[((int)dq.size()-1)/2];
            newy += dq.back()-nmid; 
            if (newy<=b) {
                tot = newy;
                ans = max(ans, ++cur);
                right++;
            }
            else {
                dq.pop_back();
                break;
            }
        }
        tot -= dq[((int)dq.size()-1)/2]-dq.front();
        if ((int)dq.size()%2==0) tot -= dq[(int)dq.size()/2]-dq[((int)dq.size()-1)/2];
        dq.pop_front();
        cur--;
    }
    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 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 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 304 KB Output is correct
10 Correct 0 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 0 ms 204 KB Output is correct
15 Correct 1 ms 300 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 300 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 308 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 0 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 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 332 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 300 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 308 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 308 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 2 ms 332 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 2 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 17 ms 2116 KB Output is correct
4 Correct 16 ms 2112 KB Output is correct
5 Correct 7 ms 844 KB Output is correct
6 Correct 7 ms 832 KB Output is correct
7 Correct 16 ms 1780 KB Output is correct
8 Correct 19 ms 1868 KB Output is correct
9 Correct 7 ms 716 KB Output is correct
10 Correct 7 ms 716 KB Output is correct
11 Correct 17 ms 2100 KB Output is correct
12 Correct 17 ms 2116 KB Output is correct
13 Correct 8 ms 844 KB Output is correct
14 Correct 8 ms 828 KB Output is correct
15 Correct 13 ms 1612 KB Output is correct
16 Correct 13 ms 1600 KB Output is correct
17 Correct 16 ms 2072 KB Output is correct
18 Correct 15 ms 1860 KB Output is correct
19 Correct 16 ms 1996 KB Output is correct
20 Correct 16 ms 1996 KB Output is correct