# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211247 | socho | Visiting Singapore (NOI20_visitingsingapore) | C++14 | 2090 ms | 99324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
const int MXK = 1005;
const int MXN = 5005;
const int MXM = 5005;
int k, n, m, a, b;
int happy[MXK];
int events[MXN];
int want[MXM];
int dp[MXN][MXM];
int solve(int planday, int realday) {
if (planday == m) return 0; // if we're at end of plan, no more to gain
if (realday == n) {
// no more days to do anything
int re = (m - planday);
int co = (re == 0) ? 0 : b * re + a;
return co;
}
if (dp[planday][realday] != INT_MIN) return dp[planday][realday];
int best = INT_MIN; // the best is nada
// let's say we skip this day of plan
// there are then m - planday - 1 remaining in plan so
for (int u=planday; u<m; u++) {
// skip until day u of plan
int skip = (u - planday + 1);
int cost = ((skip == 0) ? 0 : b * skip + a);
best = max(best, cost + solve(u+1, realday));
# | 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... |