Submission #72461

#TimeUsernameProblemLanguageResultExecution timeMemory
72461김동현보다 잘함 (#118)Gorgeous Pill (FXCUP3_gorgeous)C++14
51 / 100
22 ms14764 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...