답안 #997584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
997584 2024-06-12T14:14:55 Z Luvidi Bigger segments (IZhO19_segments) C++17
27 / 100
1500 ms 70992 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back

void solve() {
    int n;
    cin>>n;
    ll a[n+1],pre[n+1];
    pre[0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i+1];
        pre[i+1]=pre[i]+a[i+1];
    }
    ll dp[n+1][n+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=1e18;
        }
    }
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int x=1;x<=i;x++){
                if(pre[i]-pre[i-x]>=dp[i-x][j-1]){
                    dp[i][j]=min(dp[i][j],pre[i]-pre[i-x]);
                }
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(dp[n][i]<1e18)ans=i;
    }
    cout<<ans;
}

int main() {   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 70 ms 2396 KB Output is correct
17 Correct 70 ms 2396 KB Output is correct
18 Correct 73 ms 2396 KB Output is correct
19 Correct 90 ms 2396 KB Output is correct
20 Correct 103 ms 2392 KB Output is correct
21 Correct 76 ms 2396 KB Output is correct
22 Correct 37 ms 1624 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 76 ms 2404 KB Output is correct
25 Correct 79 ms 2392 KB Output is correct
26 Correct 114 ms 2396 KB Output is correct
27 Correct 78 ms 2396 KB Output is correct
28 Correct 75 ms 2392 KB Output is correct
29 Correct 103 ms 2396 KB Output is correct
30 Correct 102 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 70 ms 2396 KB Output is correct
17 Correct 70 ms 2396 KB Output is correct
18 Correct 73 ms 2396 KB Output is correct
19 Correct 90 ms 2396 KB Output is correct
20 Correct 103 ms 2392 KB Output is correct
21 Correct 76 ms 2396 KB Output is correct
22 Correct 37 ms 1624 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 76 ms 2404 KB Output is correct
25 Correct 79 ms 2392 KB Output is correct
26 Correct 114 ms 2396 KB Output is correct
27 Correct 78 ms 2396 KB Output is correct
28 Correct 75 ms 2392 KB Output is correct
29 Correct 103 ms 2396 KB Output is correct
30 Correct 102 ms 2396 KB Output is correct
31 Execution timed out 1556 ms 70992 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 70 ms 2396 KB Output is correct
17 Correct 70 ms 2396 KB Output is correct
18 Correct 73 ms 2396 KB Output is correct
19 Correct 90 ms 2396 KB Output is correct
20 Correct 103 ms 2392 KB Output is correct
21 Correct 76 ms 2396 KB Output is correct
22 Correct 37 ms 1624 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 76 ms 2404 KB Output is correct
25 Correct 79 ms 2392 KB Output is correct
26 Correct 114 ms 2396 KB Output is correct
27 Correct 78 ms 2396 KB Output is correct
28 Correct 75 ms 2392 KB Output is correct
29 Correct 103 ms 2396 KB Output is correct
30 Correct 102 ms 2396 KB Output is correct
31 Execution timed out 1556 ms 70992 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 70 ms 2396 KB Output is correct
17 Correct 70 ms 2396 KB Output is correct
18 Correct 73 ms 2396 KB Output is correct
19 Correct 90 ms 2396 KB Output is correct
20 Correct 103 ms 2392 KB Output is correct
21 Correct 76 ms 2396 KB Output is correct
22 Correct 37 ms 1624 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 76 ms 2404 KB Output is correct
25 Correct 79 ms 2392 KB Output is correct
26 Correct 114 ms 2396 KB Output is correct
27 Correct 78 ms 2396 KB Output is correct
28 Correct 75 ms 2392 KB Output is correct
29 Correct 103 ms 2396 KB Output is correct
30 Correct 102 ms 2396 KB Output is correct
31 Execution timed out 1556 ms 70992 KB Time limit exceeded
32 Halted 0 ms 0 KB -