# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
393603 | 79brue | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 1 ms | 588 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n; ll l;
ll arr[205], t[205];
ll DP[205][205][205][2]; /// l에 있는 경우 = 0, r에 있는 경우 = 1
int ans;
int main(){
scanf("%d %lld", &n, &l);
for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
for(int i=1; i<=n; i++) scanf("%lld", &t[i]);
arr[n+1] = l;
for(int i=0; i<=n+3; i++) for(int j=0; j<=n+3; j++) for(int k=0; k<=n+3; k++) DP[i][j][k][0] = DP[i][j][k][1] = 1e18;
DP[0][n+1][0][0] = DP[0][n+1][0][1] = 0;
for(int d=n+1; d>=0; d--){
for(int i=0; i<=n+1-d; i++){
int j = i+d;
for(int p=0; p<=n; p++){
ll newT; int newP;
if(DP[i][j][p][0] < 1e18){ /// 현재 i에 있는 경우
ans = max(ans, p);
if(d){
newT = DP[i][j][p][0] + (arr[i+1] - arr[i]);
newP = p + (newT <= t[i+1]);
DP[i+1][j][newP][0] = min(DP[i+1][j][newP][0], newT);
newT = DP[i][j][p][1] + l - (arr[j-1] - arr[i]);
newP = p + (newT <= t[j-1]);
DP[i][j-1][newP][1] = min(DP[i][j-1][newP][1], newT);
}
}
if(DP[i][j][p][1] < 1e18){
ans = max(ans, p);
if(d){
newT = DP[i][j][p][1] + l - (arr[j] - arr[i+1]);
newP = p + (newT <= t[i+1]);
DP[i+1][j][newP][0] = min(DP[i+1][j][newP][0], newT);
newT = DP[i][j][p][1] + (arr[j] - arr[j-1]);
newP = p + (newT <= t[j-1]);
DP[i][j-1][newP][1] = min(DP[i][j-1][newP][1], newT);
}
}
}
}
}
printf("%d", 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... |