제출 #1130674

#제출 시각아이디문제언어결과실행 시간메모리
1130674CrabCNHCandies (JOI18_candies)C++20
0 / 100
11 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[2005][2005]; // 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 { if (i >= 1) { dp[i][j] = max (dp[i - 1][j], dp[i - 2][j - 1] + a[i]); } else { dp[i][j] = dp[i - 1][j]; } } } } 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 :)

컴파일 시 표준 에러 (stderr) 메시지

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