답안 #647335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647335 2022-10-02T08:51:07 Z ByeWorld Cigle (COI21_cigle) C++14
20 / 100
1000 ms 3052 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 5e3+10;

int dp[MAXN][MAXN];//max score kalo l - r
int a[MAXN], pref[MAXN], suff[MAXN];

signed main(){
    int n; cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i]; pref[i] = pref[i-1]+a[i];
    }
    for(int i=n; i>=1; i--){
        suff[i] = suff[i+1]+a[i];
    }
    for(int i=n; i>=1; i--){
        for(int j=i; j>=1; j--){
            for(int k=n; k>=i+1; k--){//yg di atas mau apa
                //di atas i+1 --> k, di bawah j --> i
                int cnt = 0;
                int up=i+1; int dow=i;
                while(up != k && dow != j){
                    //if(j==1 && i==2 && k==4) cout << up << ' ' << dow << "he\n";
                    int atas = pref[up]-pref[i]; int bawah = suff[dow]-suff[i+1];
                    if(atas == bawah){
                        cnt++;
                        up++; dow--;
                    } else if(atas > bawah){
                        dow--;
                    } else up++;
                }
                dp[j][i] = max(dp[j][i], dp[i+1][k]+cnt);
            }
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++) ans = max(ans, dp[1][i]);
    cout << ans << '\n';
    /*for(int i=1; i<=n; i++){
        for(int j=1; j<=i; j++){
            cout << j << ' ' << i << ' ' << dp[j][i] << '\n';
        }
    }*/
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 564 KB Output is correct
19 Correct 5 ms 656 KB Output is correct
20 Correct 4 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 3052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 564 KB Output is correct
19 Correct 5 ms 656 KB Output is correct
20 Correct 4 ms 596 KB Output is correct
21 Execution timed out 1083 ms 3052 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 4 ms 596 KB Output is correct
17 Correct 4 ms 596 KB Output is correct
18 Correct 4 ms 564 KB Output is correct
19 Correct 5 ms 656 KB Output is correct
20 Correct 4 ms 596 KB Output is correct
21 Execution timed out 1083 ms 3052 KB Time limit exceeded
22 Halted 0 ms 0 KB -