Submission #1109991

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11099912024-11-08 11:32:07NoMercyFeast (NOI19_feast)C++17
4 / 100
121 ms26616 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int N, K;
cin >> N >> K;
vector<ll> arr(N + 1, 0);
for (int i = 1;i <= N;i ++) cin >> arr[i];
vector<vector<array<ll, 2>>> dp(N + 1, {{0, 0}, {0, 0}});
ll lo = 0, hi = 1e16 + 6789;
while (lo + 1 < hi) {
ll mid = (lo + hi) / 2LL;
for (int i = 1;i <= N;i ++) {
if ((dp[i - 1][0][0] == dp[i - 1][1][0] && dp[i - 1][0][1] > dp[i - 1][1][1]) || (dp[i - 1][0][0] > dp[i - 1][1][0])) {
dp[i][0] = {dp[i - 1][0][0], dp[i - 1][0][1]};
} else {
dp[i][0] = {dp[i - 1][1][0], dp[i - 1][1][1]};
}
if ((dp[i - 1][0][0] + arr[i] - mid == dp[i - 1][1][0] + arr[i] && dp[i - 1][0][1] + 1 > dp[i - 1][1][1]) || (dp[i - 1][0][0] + arr[i] - mid > dp[i - 1][1][0] + arr[i])) {
dp[i][1] = {dp[i - 1][0][0] + arr[i] - mid, dp[i - 1][0][1] + 1};
} else {
dp[i][1] = {dp[i - 1][1][0] + arr[i], dp[i - 1][1][1]};
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...