제출 #930358

#제출 시각아이디문제언어결과실행 시간메모리
930358vjudge1Feast (NOI19_feast)C++17
41 / 100
23 ms32088 KiB
#include <bits/stdc++.h> #define int long long using namespace std; template<typename T> inline bool maxi(T &x, const T &val) { if (x < val) return x = val, true; return false; } template<typename T> inline bool mini(T &x, const T &val) { if (x > val) return x = val, true; return false; } const int maxn = 2010; int n, k; int a[maxn], S[maxn]; int dp[maxn][maxn]; void solve() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i], S[i] = S[i - 1] + a[i]; for (int i = 1; i <= n; i++) { int cur = 0; for (int j = 1; j <= n; j++) { maxi(dp[i][j], dp[i][j - 1]); maxi(dp[i][j], dp[i - 1][j]); maxi(dp[i][j], cur + S[j]); maxi(cur, dp[i - 1][j] - S[j]); } } cout << dp[k][n] << '\n'; } signed main() { #ifdef LOCAL clock_t st = clock(); #endif ios_base::sync_with_stdio(false); cin.tie(0); #define Task "" #ifdef LOCAL if (!fopen("D:\\.inp", "r")) { freopen("D:\\.inp", "w", stdout); freopen("D:\\.out", "w", stdout); cerr << "get input from file\n"; return 0; } freopen("D:\\.inp", "r", stdin); freopen("D:\\.out", "w", stdout); #else if (fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } #endif solve(); #ifdef LOCAL cerr << clock() - st << endl; #endif }

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

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