Submission #72513

# Submission time Handle Problem Language Result Execution time Memory
72513 2018-08-26T08:42:23 Z 신딩없는 신딩팀(#2212, willi19, andy627, maruii) Gorgeous Pill (FXCUP3_gorgeous) C++14
51 / 100
29 ms 10168 KB
#include <stdio.h>
using namespace std;
int n;
long long c[1100],d[1100];
long long right[1100],left[1100];
long long ans[1100][1100];
long long dp(int l,int r)
{
    if(ans[l][r]!=-1) return ans[l][r];
    if(l==0) return right[r];
    if(r==0) return left[l];
    long long ret1=dp(l-1,r);
    if(c[n-l]==n-l-r+1) ret1+=d[n-l];
    long long ret2=dp(l,r-1);
    if(c[r-1]==n-l-r+1) ret2+=d[r-1];
    ans[l][r]=ret1>ret2?ret1:ret2;
    //printf("%d %d %lld\n",l,r,ans[l][r]);
    return ans[l][r];

}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld",&c[i]);
    for(int j=0;j<n;j++) scanf("%lld",&d[j]);
    for(int j=1;j<n+1;j++)
        if(n-j+1==c[j-1]) right[j]+=d[j-1];
    for(int j=0;j<n;j++)
        right[j+1]+=right[j];
    for(int j=1;j<n+1;j++)
        if(n-j+1==c[n-j]) left[j]+=d[n-j];
    for(int j=0;j<n;j++)
        left[j+1]+=left[j];
    for(int i=0;i<1100;i++)
        for(int j=0;j<1100;j++)
            ans[i][j]=-1;
    for(int i=0;i<n;i++)
    {
        if(c[i]==1)
            printf("%lld ",dp(n-i-1,i)+d[i]);
        else
            printf("%lld ",dp(n-i-1,i));
    }
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
gorgeous.cpp:24:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%lld",&c[i]);
                          ~~~~~^~~~~~~~~~~~~~
gorgeous.cpp:25:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int j=0;j<n;j++) scanf("%lld",&d[j]);
                          ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 10 ms 9856 KB Output is correct
3 Correct 9 ms 9932 KB Output is correct
4 Correct 11 ms 9980 KB Output is correct
5 Correct 11 ms 10012 KB Output is correct
6 Correct 13 ms 10148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 10 ms 9856 KB Output is correct
3 Correct 9 ms 9932 KB Output is correct
4 Correct 11 ms 9980 KB Output is correct
5 Correct 11 ms 10012 KB Output is correct
6 Correct 13 ms 10148 KB Output is correct
7 Correct 10 ms 10148 KB Output is correct
8 Correct 10 ms 10148 KB Output is correct
9 Correct 9 ms 10148 KB Output is correct
10 Correct 10 ms 10148 KB Output is correct
11 Correct 22 ms 10148 KB Output is correct
12 Correct 19 ms 10168 KB Output is correct
13 Correct 29 ms 10168 KB Output is correct
14 Correct 28 ms 10168 KB Output is correct
15 Correct 22 ms 10168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 9720 KB Output is correct
2 Correct 10 ms 9856 KB Output is correct
3 Correct 9 ms 9932 KB Output is correct
4 Correct 11 ms 9980 KB Output is correct
5 Correct 11 ms 10012 KB Output is correct
6 Correct 13 ms 10148 KB Output is correct
7 Correct 10 ms 10148 KB Output is correct
8 Correct 10 ms 10148 KB Output is correct
9 Correct 9 ms 10148 KB Output is correct
10 Correct 10 ms 10148 KB Output is correct
11 Correct 22 ms 10148 KB Output is correct
12 Correct 19 ms 10168 KB Output is correct
13 Correct 29 ms 10168 KB Output is correct
14 Correct 28 ms 10168 KB Output is correct
15 Correct 22 ms 10168 KB Output is correct
16 Execution timed out 2 ms 10168 KB Time limit exceeded (wall clock)
17 Halted 0 ms 0 KB -