| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 755280 | He_Huanglu | Feast (NOI19_feast) | C++17 | 313 ms | 18628 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ii pair<long long, int>
#define fi first
#define se second
using namespace std;
const int N = 3e5 + 5;
int n, k, a[N];
long long ans, tax, l, r = 1e18;
ii f[N][3];
main () {
cin.tie(0)->sync_with_stdio(0);
if(fopen("task.inp", "r")) {
freopen("task.inp", "r", stdin);
freopen("wa.out", "w", stdout);
}
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> a[i];
f[1][1].fi = -1e18;
while (l <= r) {
tax = (l + r) >> 1;
f[1][2] = {a[1] - tax, 1};
for(int i = 2; i <= n; i++) {
f[i][0] = max({f[i - 1][0], f[i - 1][1], f[i - 1][2]});
f[i][1] = max(f[i - 1][1], f[i - 1][2]);
f[i][1].fi += a[i];
f[i][2] = {f[i][0].fi + a[i] - tax, f[i][0].se + 1};
}
ii tmp = max({f[n][0], f[n][1], f[n][2]});
if(tmp.se <= k) {
ans = tmp.fi + tax * tmp.se;
r = tax - 1;
}
else l = tax + 1;
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
