답안 #969907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969907 2024-04-25T19:23:41 Z urieg 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 4184 KB

#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
/// for moondance

int besthub(int R, int L, int X[], long long B){

    vector<ll>x(R), p(R);
    for(int i=0;i<R;i++){
        x[i] = X[i];
        p[i] = x[i];
        if(i)p[i] += p[i-1];
    }


    int ans = 0;
    ll sum = 0;
    int l = 0, r = 0;
    for(int i =0;i<R;i++){
        l = r = i;
        sum = 0;
        while((l>0 || r<R-1) && sum <= B){
            if(l>0 && r<R-1){
                if(x[i]-x[l-1] < x[r+1]-x[i]){
                    if(sum + x[i]-x[l-1] <= B){
                        sum += x[i]-x[l-1];
                        l--;
                    }
                    else break;
                }
                else{
                    if(sum + x[r+1]-x[i] <= B){
                        sum += x[r+1]-x[i];
                        r++;
                    }
                    else break;
                }
            }
            else if(l>0){
                if(sum + x[i]-x[l-1] <= B){
                    sum += x[i]-x[l-1];
                    l--;
                }
                else break;
            }
            else if(r<R-1){
                if(sum + x[r+1]-x[i] <= B){
                    sum += x[r+1]-x[i];
                    r++;
                }
                else break;
            }
        }
        ans = max(ans, r-l+1);
    }
    return ans;
}




# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 460 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 30 ms 344 KB Output is correct
24 Correct 29 ms 348 KB Output is correct
25 Correct 78 ms 348 KB Output is correct
26 Correct 76 ms 568 KB Output is correct
27 Correct 21 ms 344 KB Output is correct
28 Correct 19 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 604 KB Output is correct
2 Correct 4 ms 604 KB Output is correct
3 Execution timed out 1002 ms 4184 KB Time limit exceeded
4 Halted 0 ms 0 KB -