| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 666457 | hoanghq2004 | Feast (NOI19_feast) | C++14 | 120 ms | 10524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 3e5 + 10;
int n, k;
long long s[N];
pair <long long, int> f[N];
int calc(long long C) {
pair <long long, int> opt = {0, 0};
for (int i = 1; i <= n; ++i) {
f[i].first = opt.first + s[i] - C;
f[i].second = opt.second - 1;
if (f[i] < f[i - 1]) f[i] = f[i - 1];
if (make_pair(f[i].first - s[i], f[i].second) > opt)
opt = make_pair(f[i].first - s[i], f[i].second);
}
return - f[n].second;
}
int main() {
ios :: sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
cin >> s[i];
s[i] += s[i - 1];
}
if (calc(0) <= k) {
cout << f[n].first << '\n';
exit(0);
}
long long L = 0, R = 1e14;
while (L < R) {
long long mid = L + R >> 1;
if (calc(mid) <= k) R = mid;
else L = mid + 1;
}
calc(L);
cout << f[n].first + 1LL * k * L << '\n';
}
컴파일 시 표준 에러 (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... | ||||
