제출 #669490

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
6694902022-12-06 14:43:46GrandTiger1729Collecting Stamps 3 (JOI20_ho_t3)C++17
100 / 100
162 ms126148 KiB
#include <iostream>
using namespace std;
const long long INF = 1e18;
int main(){
int n;
long long L;
cin >> n >> L;
long long a[n], b[n];
for (int i = 0; i < n; i++){
cin >> a[i];
}
for (int i = 0; i < n; i++){
cin >> b[i];
}
auto idx = [&](int i) -> int {
return (i % n + n) % n;
};
auto dis = [&](long long x, long long y) -> long long {
if (x > y) swap(x, y);
return min(y - x, x + L - y);
};
long long dp[n][n][n + 1][2]{}; // [l, r], pickcnt, cur(l, r) => min time
fill_n(&dp[0][0][0][0], sizeof(dp) / sizeof(long long), INF);
for (int i = 0; i < n; i++){
dp[i][i][min(a[i], L - a[i]) <= b[i]][0] = dp[i][i][min(a[i], L - a[i]) <= b[i]][1] = min(a[i], L - a[i]);
}
for (int t = 0; t < n - 1; t++){
for (int l = n - 1; l >= 0; l--){
int r = idx(l + t);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...