# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72528 | IDxTree (#118) | 재채점 전쟁 (FXCUP3_judge) | C++17 | 2 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
int n;
int c[1001];
int d[1001];
llong dp[1001][1001];
int cost(int i, int cnt) {
if (c[i] != cnt) return 0;
return d[i];
}
llong pro_dp(int s, int e) {
if (dp[s][e] != -1) return dp[s][e];
int cnt = e - s + 2;
if (s > 1) dp[s][e] = max(dp[s][e], pro_dp(s - 1, e) + cost(s - 1, cnt));
if (e < n) dp[s][e] = max(dp[s][e], pro_dp(s, e + 1) + cost(e + 1, cnt));
return dp[s][e];
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", c + i);
for (int i = 1; i <= n; ++i) scanf("%d", d + i);
for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) dp[i][j] = -1;
dp[1][n] = 0;
for (int i = 1; i <= n; ++i) printf("%lld ", pro_dp(i, i) + cost(i, 1));
return 0;
}
컴파일 시 표준 에러 (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... |