# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
587997 |
2022-07-02T15:56:04 Z |
Temmie |
Feast (NOI19_feast) |
C++17 |
|
1000 ms |
37096 KB |
#include <bits/stdc++.h>
typedef std::pair <long long, int> pa;
int n, k;
std::vector <int> a;
pa g(int l) {
std::vector <std::vector <pa>> dp(n, std::vector <pa> (2, { -1, -1 }));
auto f = [&] (auto&& self, int i, bool is) -> pa {
if (i >= n) {
return { 0, 0 };
}
if (dp[i][is].first != -1) {
return dp[i][is];
}
dp[i][is] = self(self, i + 1, false);
pa cand = self(self, i + 1, true);
cand.second += !is;
cand.first += a[i];
cand.first -= l * !is;
dp[i][is] = std::max(dp[i][is], cand);
return dp[i][is];
};
return f(f, 0, false);
}
int main() {
std::ios::sync_with_stdio(0); std::cin.tie(0);
std::cin >> n >> k;
a.resize(n);
for (int& x : a) {
std::cin >> x;
}
long long l = 0, r = 1LL << 60, ans = 0;
while (l <= r) {
long long mid = (l + r) >> 1;
pa val = g(mid);
if (val.first >= mid) {
l = mid + 1;
ans = val.first + mid * k;
} else {
r = mid - 1;
}
}
std::cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
36424 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
36632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
37096 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
36424 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |