Submission #72391

#TimeUsernameProblemLanguageResultExecution timeMemory
72391 (#118)Gorgeous Pill (FXCUP3_gorgeous)C++14
51 / 100
501 ms14456 KiB
#include <cstdio> #include <algorithm> using namespace std; long long dp[2][1002][1002]; // 너비, 구간 시작점, 첫 약 int C[1002]; int D[1002]; int main(){ int N; scanf("%d", &N); if(N > 1000){ puts("Subtask 3"); return 0; } for(int i = 1; i <= N; i++) scanf("%d", &C[i]); for(int i = 1; i <= N; i++) scanf("%d", &D[i]); for(int i = 1; i <= N; i++) dp[1][i][i] = (C[i] == 1 ? D[i] : 0); for(int w = 2; w <= N; w++){ int w_ = w & 1, _w = w_ ^ 1; int e = N - w + 1; for(int i = 1; i <= e; i++){ int fe = i + w - 1; for(int f = i; f <= fe; f++){ // 마지막 약으로 구간의 시작점 or 구간의 끝점 long long a = f < fe ? dp[_w][i][f] + (C[fe] == w ? D[fe] : 0) : 0; long long b = f > i ? dp[_w][i + 1][f] + (C[i] == w ? D[i] : 0) : 0; dp[w_][i][f] = max(a, b); } } } for(int i = 1; i <= N; i++) printf("%lld ", dp[N & 1][1][i]); printf("\n"); return 0; }

Compilation message (stderr)

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:11:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int N; scanf("%d", &N);
          ~~~~~^~~~~~~~~~
gorgeous.cpp:18:36: 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", &C[i]);
                               ~~~~~^~~~~~~~~~~~~
gorgeous.cpp:19:36: 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", &D[i]);
                               ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...