답안 #964009

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

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

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/3;
            }
        }
    }

    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/3;
            }
        }
    }

    ll 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++){
        ll 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 0 ms 348 KB Output is correct
2 Correct 0 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 0 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 1372 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 1368 KB Output is correct
16 Correct 1 ms 1368 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 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 8448 KB Output is correct
22 Correct 4 ms 8280 KB Output is correct
23 Correct 4 ms 8284 KB Output is correct
24 Correct 4 ms 8440 KB Output is correct
25 Correct 4 ms 8284 KB Output is correct
26 Correct 4 ms 8284 KB Output is correct
27 Correct 4 ms 8284 KB Output is correct
28 Correct 4 ms 8284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 1 ms 2236 KB Output is correct
3 Correct 11 ms 20572 KB Output is correct
4 Correct 11 ms 20572 KB Output is correct
5 Correct 4 ms 8380 KB Output is correct
6 Correct 6 ms 8284 KB Output is correct
7 Correct 15 ms 24292 KB Output is correct
8 Correct 13 ms 24224 KB Output is correct
9 Correct 4 ms 8284 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 8 ms 16988 KB Output is correct
12 Correct 8 ms 16988 KB Output is correct
13 Correct 13 ms 24156 KB Output is correct
14 Correct 13 ms 24156 KB Output is correct
15 Correct 4 ms 8284 KB Output is correct
16 Correct 4 ms 8384 KB Output is correct
17 Correct 9 ms 16988 KB Output is correct
18 Correct 9 ms 16988 KB Output is correct
19 Correct 13 ms 24156 KB Output is correct
20 Correct 16 ms 24408 KB Output is correct
21 Runtime error 145 ms 262144 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 186 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -