답안 #394427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394427 2021-04-26T15:37:44 Z vishesh312 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 3224 KB
#include "bits/stdc++.h"
#include "ricehub.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()

using ll = long long;
const int mod = 1e9+7;

int besthub(int r, int l, int x[], ll b) {
    vector<ll> v(x, x+r);
    vector<ll> pre(r+1);
    for (int i = 0; i < r; ++i) pre[i+1] = pre[i] + v[i];
    int ans = 0;
    for (ll st = 0; st < r; ++st) {
        for (ll ed = st; ed < r; ++ed) {
            ll mid = (st + ed) / 2;
            ll cost = (mid - st) * v[mid] - (pre[mid] - pre[st]) + (pre[ed+1] - pre[mid+1]) - (ed - mid) * v[mid];
            if (cost <= b) 
                ans = max((ll)ans, ed-st+1);
        }
    }
    return ans;
}
/*
int main() {
    int r, l, b;
    cin >> r >> l >> b;
    int a[r];
    for (int i =0 ; i < r; ++i) cin >> a[i];
    cout << besthub(r, l, a, b);
}
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 308 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 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 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 308 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 304 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 208 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 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 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 2 ms 332 KB Output is correct
8 Correct 2 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 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 2 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 2 ms 204 KB Output is correct
19 Correct 2 ms 316 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
21 Correct 27 ms 332 KB Output is correct
22 Correct 26 ms 432 KB Output is correct
23 Correct 32 ms 332 KB Output is correct
24 Correct 34 ms 332 KB Output is correct
25 Correct 32 ms 332 KB Output is correct
26 Correct 32 ms 332 KB Output is correct
27 Correct 31 ms 332 KB Output is correct
28 Correct 31 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 440 ms 828 KB Output is correct
2 Correct 395 ms 716 KB Output is correct
3 Execution timed out 1092 ms 3224 KB Time limit exceeded
4 Halted 0 ms 0 KB -