Submission #1309103

#TimeUsernameProblemLanguageResultExecution timeMemory
1309103lyra_g13Feast (NOI19_feast)C++20
0 / 100
149 ms327680 KiB
#include <bits/stdc++.h> using ll = int; using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); ll n, k; cin >> n >> k; vector<ll> a(n); vector<ll> pref(n + 1); vector<vector<ll>> dp(k + 1, vector<ll>(n + 1)); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { pref[i] = pref[i - 1] + a[i - 1]; } for (int j = 1; j <= k; j++) { ll best = -1e18; for (int i = 1; i <= n; i++) { best = max(best, dp[j - 1][i - 1] - pref[i - 1]); dp[j][i] = best + pref[i]; dp[j][i] = max(dp[j][i - 1], dp[j][i]); if(dp[j][i] < 0) dp[j][i] = 0; } } cout << dp[k][n] << "\n"; return 0; }

Compilation message (stderr)

feast.cpp: In function 'int main()':
feast.cpp:23:15: warning: overflow in conversion from 'double' to 'll' {aka 'int'} changes value from '-1.0e+18' to '-2147483648' [-Woverflow]
   23 |     ll best = -1e18;
      |               ^~~~~
#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...