Submission #72461

# Submission time Handle Problem Language Result Execution time Memory
72461 2018-08-26T08:20:41 Z 김동현보다 잘함(#2226, tlwpdus) Gorgeous Pill (FXCUP3_gorgeous) C++14
51 / 100
22 ms 14764 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n;
ll D[1010][1010];
int C[1010];
ll A[1010];

int main() {
    int i;

    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%d",&C[i]);
    for (i=0;i<n;i++) scanf("%lld",&A[i]);
    for (i=n-2;i>=0;i--) {
        for (int s = 0;s+i<n;s++) {
            int e = s+i;
            D[s][e] = max(s?D[s-1][e]+(C[s-1]==e-s+2)*A[s-1]:0,
                          e!=n-1?D[s][e+1]+(C[e+1]==e-s+2)*A[e+1]:0);
        }
    }
    for (i=0;i<n;i++) printf("%lld ",D[i][i]+((C[i]==1)?A[i]:0));
    printf("\n");

    return 0;
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
gorgeous.cpp:18:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i=0;i<n;i++) scanf("%d",&C[i]);
                       ~~~~~^~~~~~~~~~~~
gorgeous.cpp:19:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i=0;i<n;i++) scanf("%lld",&A[i]);
                       ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 3 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 3 ms 544 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 2 ms 924 KB Output is correct
9 Correct 3 ms 1112 KB Output is correct
10 Correct 5 ms 2540 KB Output is correct
11 Correct 11 ms 5740 KB Output is correct
12 Correct 10 ms 7036 KB Output is correct
13 Correct 11 ms 7564 KB Output is correct
14 Correct 12 ms 7580 KB Output is correct
15 Correct 12 ms 7596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 3 ms 544 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 2 ms 924 KB Output is correct
9 Correct 3 ms 1112 KB Output is correct
10 Correct 5 ms 2540 KB Output is correct
11 Correct 11 ms 5740 KB Output is correct
12 Correct 10 ms 7036 KB Output is correct
13 Correct 11 ms 7564 KB Output is correct
14 Correct 12 ms 7580 KB Output is correct
15 Correct 12 ms 7596 KB Output is correct
16 Runtime error 22 ms 14764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Halted 0 ms 0 KB -