Submission #1130672

#TimeUsernameProblemLanguageResultExecution timeMemory
1130672CrabCNHCandies (JOI18_candies)C++20
0 / 100
10 ms16192 KiB
#include <bits/stdc++.h> #define task "BriantheCrab" #define int long long #define pii pair <int, int> #define fi first #define se second #define szf sizeof #define sz(s) (int)((s).size()) using namespace std; template <class T> void mini (T &t, T f) {if (t > f) t = f;} template <class T> void maxi (T &t, T f) {if (t < f) t = f;} const int maxN = 1e5 + 5; const int inf = 1e9 + 7; const int mod = 1e9 + 7; int n; int a[maxN]; namespace sub1 { int dp[2001][2001]; // max val at the i-th place and choose j void sol () { for (int i = 1; i <= n; i ++) { for (int j = 0; j <= (i + 1) / 2; j ++) { if (j == 0) { dp[i][j] = max (dp[i - 1][j], 0LL); } else { dp[i][j] = max (dp[i - 1][j], dp[i - 2][j - 1] + a[i]); } } } for (int i = 1; i <= (n + 1) / 2; i ++) { cout << dp[n][i] << '\n'; } } } void Solve () { cin >> n; for (int i = 1; i <= n; i ++) { cin >> a[i]; } sub1 :: sol (); } signed main () { cin.tie (nullptr) -> sync_with_stdio (false); if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int t = 1; //cin >> t; while (t --) { Solve (); } return 0; } // Belligerent :)

Compilation message (stderr)

candies.cpp: In function 'int main()':
candies.cpp:55:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
candies.cpp:56:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...