Submission #47828

#TimeUsernameProblemLanguageResultExecution timeMemory
47828mirbek01Candies (JOI18_candies)C++17
8 / 100
19 ms12448 KiB
# include <bits/stdc++.h> using namespace std; const int N = 2e3 + 2; int n, a[N]; long long dp[N][N]; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i ++){ cin >> a[i]; dp[1][i] = max(dp[1][i - 1], 1ll* a[i]); } for(int i = 2; i <= (n + 1) / 2; i ++){ for(int j = i * 2 - 1; j <= n; j ++){ dp[i][j] = max(dp[i - 1][j - 2] + a[j], dp[i][j - 1]); } } for(int i = 1; i <= (n + 1) / 2; i ++){ cout << dp[i][n] << endl; } }

Compilation message (stderr)

candies.cpp: In function 'int main()':
candies.cpp:11:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &n);
       ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...