제출 #970013

#제출 시각아이디문제언어결과실행 시간메모리
970013blackslexFeast (NOI19_feast)C++17
59 / 100
115 ms262144 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int n, k;

int main() {
    scanf("%d %d", &n, &k);
    vector<ll> a(n + 5), pref(n + 5);
    vector<vector<ll>> dp(n + 5, vector<ll>(k + 5));
    vector<ll> dp2(k + 5);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), pref[i] = pref[i - 1] + a[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) dp[i][j] = max(dp[i - 1][j], dp2[j - 1] + pref[i]);
        for (int j = 0; j <= k; j++) dp2[j] = max(dp2[j], dp[i][j] - pref[i]);
    }
    printf("%lld", dp[n][k]);
}

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

feast.cpp: In function 'int main()':
feast.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
feast.cpp:13:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), pref[i] = pref[i - 1] + a[i];
      |                                  ~~~~~^~~~~~~~~~~~~~~
#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...