Submission #634453

# Submission time Handle Problem Language Result Execution time Memory
634453 2022-08-24T12:41:06 Z Cross_Ratio Gorgeous Pill (FXCUP3_gorgeous) C++14
12 / 100
1500 ms 7736 KB
#include <bits/stdc++.h>
using namespace std;
int C[300005];
long long int D[300005];
long long int DP[1005][1005];
const long long int INF = 1e18;
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    int i, j;
    for(i=0;i<N;i++) cin >> C[i];
    for(i=0;i<N;i++) cin >> D[i];
    for(i=0;i<N;i++) {
        for(j=0;j<N;j++) {
            for(int k = 0; k <= N; k++) DP[j][k] = -INF;
        }
        DP[i][i+1] = (C[i]==1 ? D[i] : 0);
        for(int len = 1; len < N; len++) {
            for(j=0;j+len<=N;j++) {
                if(j+len+1<=N) {
                    DP[j][j+len+1] = max(DP[j][j+len+1], DP[j][j+len] + (C[j+len] == len + 1 ? D[j + len] : 0));
                }
                if(j >= 1) {
                    DP[j-1][j+len] = max(DP[j-1][j+len], DP[j][j+len] + (C[j-1] == len + 1 ? D[j-1] : 0));
                }
            }
        }
        cout << DP[0][N] << ' ';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 4 ms 840 KB Output is correct
10 Correct 95 ms 2892 KB Output is correct
11 Correct 864 ms 6464 KB Output is correct
12 Execution timed out 1586 ms 7736 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 4 ms 840 KB Output is correct
10 Correct 95 ms 2892 KB Output is correct
11 Correct 864 ms 6464 KB Output is correct
12 Execution timed out 1586 ms 7736 KB Time limit exceeded
13 Halted 0 ms 0 KB -