Submission #589655

# Submission time Handle Problem Language Result Execution time Memory
589655 2022-07-05T05:17:48 Z 박상훈(#8406) Gorgeous Pill (FXCUP3_gorgeous) C++14
51 / 100
29 ms 16736 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
ll dp[1010][1010];
int a[300300], c[300300];

int f(int i, int t){
    if (c[i]==t) return a[i];
    return 0;
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++) scanf("%d", c+i);
    for (int i=1;i<=n;i++) scanf("%d", a+i);

    for (int i=1;i<=n;i++){
        for (int j=n;j>=i;j--){
            if (i>1) dp[i][j] = max(dp[i][j], dp[i-1][j] + f(i-1, j-i+2));
            if (j<n) dp[i][j] = max(dp[i][j], dp[i][j+1] + f(j+1, j-i+2));
        }
    }
    for (int i=1;i<=n;i++) printf("%lld ", dp[i][i] + f(i, 1));
    return 0;
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
gorgeous.cpp:16:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for (int i=1;i<=n;i++) scanf("%d", c+i);
      |                            ~~~~~^~~~~~~~~~~
gorgeous.cpp:17:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     for (int i=1;i<=n;i++) scanf("%d", a+i);
      |                            ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 308 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 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 688 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 4 ms 5460 KB Output is correct
12 Correct 6 ms 6724 KB Output is correct
13 Correct 7 ms 7252 KB Output is correct
14 Correct 7 ms 7284 KB Output is correct
15 Correct 6 ms 7252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 308 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 468 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 688 KB Output is correct
10 Correct 2 ms 2260 KB Output is correct
11 Correct 4 ms 5460 KB Output is correct
12 Correct 6 ms 6724 KB Output is correct
13 Correct 7 ms 7252 KB Output is correct
14 Correct 7 ms 7284 KB Output is correct
15 Correct 6 ms 7252 KB Output is correct
16 Runtime error 29 ms 16736 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -