답안 #963997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963997 2024-04-16T07:31:12 Z Hugo1729 쌀 창고 (IOI11_ricehub) C++11
42 / 100
1000 ms 262144 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;

ll a[5000][5001], b[5000][5001];

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

    for(int i=0;i<R;i++){
        for(int j=0;j<=R;j++){
            if(j==0){
                a[i][j]=0;
            }
            else if(j-1<=i){
                a[i][j]=a[i-1][j-1]+(X[i]-X[i-1])*(j-1);
            }else{
                a[i][j]=LLONG_MAX;
            }
        }
    }

    for(int i=R-1;i>=0;i--){
        for(int j=0;j<=R;j++){
            if(j==0){
                b[i][j]=0;
            }
            else if(j<=R-i-1){
                b[i][j]=b[i+1][j-1]+(X[i+1]-X[i])*j;
            }else{
                b[i][j]=LLONG_MAX;
            }
        }
    }

    int ans=0;

    // for(int i=0;i<R;i++){
    //     for(int j=0;j<=R;j++){
    //         cout << a[i][j] << ' ';
    //     }
    //     cout << '\n';
    // }

    // for(int i=0;i<R;i++){
    //     for(int j=0;j<=R;j++){
    //         cout << b[i][j] << ' ';
    //     }
    //     cout << '\n';
    // }

    for(int i=0;i<R;i++){
        int ptr=R;
        for(int j=0;j<=R;j++){
            if(a[i][j]>B||ptr<0)break;
            while(a[i][j]+b[i][ptr]>B){
                ptr--;
                if(ptr<0)break;
            }
            if(ptr<0)break;

            // cout << i << ' ' << j << ' ' << ptr << '\n';

            ans=max(ans,j+ptr);
        }
    }



    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 676 KB Output is correct
15 Correct 1 ms 1624 KB Output is correct
16 Correct 1 ms 1372 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 856 KB Output is correct
19 Correct 1 ms 1372 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 4 ms 8284 KB Output is correct
22 Correct 4 ms 8280 KB Output is correct
23 Correct 6 ms 8276 KB Output is correct
24 Correct 4 ms 8284 KB Output is correct
25 Correct 4 ms 8288 KB Output is correct
26 Correct 4 ms 8284 KB Output is correct
27 Correct 4 ms 8280 KB Output is correct
28 Correct 6 ms 8284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 11 ms 20572 KB Output is correct
4 Correct 11 ms 20412 KB Output is correct
5 Correct 4 ms 8280 KB Output is correct
6 Correct 4 ms 8284 KB Output is correct
7 Correct 12 ms 24176 KB Output is correct
8 Correct 13 ms 24156 KB Output is correct
9 Correct 5 ms 8284 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 10 ms 16732 KB Output is correct
12 Correct 9 ms 16856 KB Output is correct
13 Correct 13 ms 24156 KB Output is correct
14 Correct 14 ms 24156 KB Output is correct
15 Correct 4 ms 8280 KB Output is correct
16 Correct 5 ms 8284 KB Output is correct
17 Correct 10 ms 16900 KB Output is correct
18 Correct 10 ms 16728 KB Output is correct
19 Correct 13 ms 24152 KB Output is correct
20 Correct 12 ms 24408 KB Output is correct
21 Runtime error 146 ms 262144 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2458 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -