Submission #963996

# Submission time Handle Problem Language Result Execution time Memory
963996 2024-04-16T07:28:00 Z Hugo1729 Rice Hub (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)break;
            while(a[i][j]+b[i][ptr]>B)ptr--;

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

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



    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 1112 KB Output is correct
6 Correct 1 ms 1112 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1124 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 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 860 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 1372 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 1120 KB Output is correct
19 Correct 1 ms 1288 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 6 ms 8284 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 8280 KB Output is correct
25 Correct 5 ms 8284 KB Output is correct
26 Correct 5 ms 8284 KB Output is correct
27 Correct 6 ms 8376 KB Output is correct
28 Correct 5 ms 8380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2240 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 11 ms 20644 KB Output is correct
4 Correct 16 ms 20416 KB Output is correct
5 Correct 6 ms 8284 KB Output is correct
6 Correct 4 ms 8284 KB Output is correct
7 Correct 12 ms 24152 KB Output is correct
8 Correct 14 ms 24152 KB Output is correct
9 Correct 4 ms 8284 KB Output is correct
10 Correct 4 ms 8284 KB Output is correct
11 Correct 9 ms 16988 KB Output is correct
12 Correct 10 ms 16944 KB Output is correct
13 Correct 18 ms 24152 KB Output is correct
14 Correct 14 ms 24244 KB Output is correct
15 Correct 4 ms 8296 KB Output is correct
16 Correct 4 ms 8284 KB Output is correct
17 Correct 9 ms 16732 KB Output is correct
18 Correct 9 ms 16780 KB Output is correct
19 Correct 14 ms 24008 KB Output is correct
20 Correct 13 ms 24156 KB Output is correct
21 Runtime error 134 ms 262144 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2421 ms 262144 KB Time limit exceeded
2 Halted 0 ms 0 KB -