Submission #72229

#TimeUsernameProblemLanguageResultExecution timeMemory
72229마릴린 희정 (#118)Gorgeous Pill (FXCUP3_gorgeous)C++14
51 / 100
16 ms9560 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; const int MAXN = 1050; lint dp[MAXN][MAXN]; int n, a[MAXN], b[MAXN]; lint f(int s, int e){ if(~dp[s][e]) return dp[s][e]; lint ret = 0; if(s > 1){ ret = max(ret, f(s - 1, e) + (a[s - 1] == (e - s + 2) ? b[s - 1] : 0)); } if(e < n){ ret = max(ret, f(s, e + 1) + (a[e + 1] == (e - s + 2) ? b[e + 1] : 0)); } return dp[s][e] = ret; } int main(){ scanf("%d",&n); if(n > 1000 ) return 0; for(int i=1; i<=n; i++) scanf("%d",&a[i]); for(int i=1; i<=n; i++) scanf("%d",&b[i]); memset(dp, -1, sizeof(dp)); for(int i=1; i<=n; i++){ lint ans = f(i, i); if(a[i] == 1) ans += b[i]; printf("%lld ", ans); } }

Compilation message (stderr)

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
gorgeous.cpp:26:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%d",&a[i]);
                          ~~~~~^~~~~~~~~~~~
gorgeous.cpp:27:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%d",&b[i]);
                          ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...