# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
632631 | phungha | Feast (NOI19_feast) | C++14 | 135 ms | 9236 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, k, cnt[300001];
long long s[300001], dp[300001];
int calc(long long lambda) {
// dp[i]: tổng lớn nhất của các đoạn với i phần tử đầu tiên, nếu mỗi đoạn khác rỗng được trừ đi lambda
// cnt[i]: số đoạn tối thiểu
dp[0] = cnt[0] = 0;
long long dp_max = 0;
int cnt_max = 0;
for (int i = 1; i <= n; i++) {
// không dùng thêm đoạn
dp[i] = dp[i - 1];
cnt[i] = cnt[i - 1];
// sử dụng thêm đoạn
if ((dp_max + s[i] - lambda > dp[i]) || (dp_max + s[i] - lambda == dp[i] && cnt[i] > cnt_max + 1)) {
dp[i] = dp_max + s[i] - lambda;
cnt[i] = cnt_max + 1;
}
if ((dp[i] - s[i] > dp_max) || (dp[i] - s[i] == dp_max && cnt_max > cnt[i])) {
dp_max = dp[i] - s[i];
cnt_max = cnt[i];
}
}
return cnt[n];
}
# | 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... |