Submission #1094225

#TimeUsernameProblemLanguageResultExecution timeMemory
1094225Trisanu_DasFeast (NOI19_feast)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second int n, k, a[300005]; pair<int, int> dp[300005]; pair<int, int> calc(int mid){ pair<int, int> curr(0,0); for(int i = 1; i <= n; i++){ dp[i] = max(dp[i - 1], {curr.ff + a[i] - mid, curr.ss + 1}); curr = max(curr, {dp[i].ff - a[i], dp[i].ss}); } return dp[n]; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) a[i] += a[i - 1]; int l = 0, r = 3e14; while(l < r){ int mid = (l + r + 1) / 2; if(calc(mid).ss >= k) l = mid; else r = m - 1; } cout << calc(l).ff + l * k << '\n'; }

Compilation message (stderr)

feast.cpp: In function 'int main()':
feast.cpp:28:18: error: 'm' was not declared in this scope
   28 |         else r = m - 1;
      |                  ^