# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
208937 | eriksuenderhauf | Collecting Stamps 3 (JOI20_ho_t3) | C++11 | 81 ms | 135160 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e2 + 5;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int X[N], T[N], n, l, ans = 0;
ll dp[N][N][N][2];
ll dist(int i, int j) { return min(abs(X[i]-X[j]), l - abs(X[i]-X[j])); }
void ckmn(ll& x, ll y) { x = min(x, y); }
int main() {
scanf("%d %d", &n, &l);
for (int i = 1; i <= n; i++) scanf("%d", X+i);
for (int i = 1; i <= n; i++) scanf("%d", T+i);
memset(dp, 0x3f, sizeof dp);
dp[0][0][0][0] = dp[0][0][0][1] = 0;
for (int i = 0; i < n; i++) {
for (int r = 0, l = i; r <= i; r++, l--) {
ll v;
for (int k = 0; k <= i; k++) {
v = dp[l][r][k][0] + dist(n+1-l, n-l);
ckmn(dp[l+1][r][k + v <= T[n-l]][0], v);
v = dp[l][r][k][0] + dist(n+1-l, r+1);
ckmn(dp[l][r+1][k + v <= T[r+1]][1], v);
v = dp[l][r][k][1] + dist(r, n-l);
ckmn(dp[l+1][r][k + v <= T[n-l]][0], v);
v = dp[l][r][k][1] + dist(r, r+1);
ckmn(dp[l][r+1][k + v <= T[r+1]][1], v);
}
}
}
for (int i = 0; i <= n; i++)
for (int j = 0; j <= n; j++)
for (int k = 0; k <= n; k++)
for (int f = 0; f < 2; f++)
if (dp[i][j][k][f] != inf)
ans = max(ans, k);
printf("%d\n", ans);
}
컴파일 시 표준 에러 (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... |