| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1025601 | ach00 | Feast (NOI19_feast) | C++14 | 177 ms | 192548 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
vector<ll> W;
vector<vector<vector<ll>>> dp(2, vector<vector<ll>>(2005, vector<ll>(2005, -1)));
ll solve(int i, int l, bool w) {
if(dp[w][i][l] != -1) return dp[w][i][l];
if(l > k || i >= n) return 0;
ll ans = numeric_limits<int>::min();
if(w == false) {
ans = max(ans, solve(i+1, l , false));
ans = max(ans, solve(i+1, l+1, true));
} else {
ans = max(ans, solve(i+1, l, true));
ans = max(ans, solve(i+1, l, false));
}
ans += (w) ? W[i] : 0;
dp[w][i][l] = ans;
return ans;
}
int main() {
cin >> n >> k;
W.resize(n); for(auto &a : W) cin >> a;
cout << max(solve(0, 0, false), solve(0, 1, true));
}| # | 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... | ||||
