# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
758224 | xyzxyz | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 0 ms | 0 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>
#define int long long
using namespace std;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, laenge; cin >> n >> laenge;
vector<int> wo(n+2, 0), zeit(n+2, 0);
for(int i=1; i<=n; i++) cin >> wo[i];
for(int i=1; i<=n; i++) cin >> zeit[i];
wo[n+1] = laenge;
zeit[n+1] = 0;
vector<vector<vector<vector<int>>>> dp(n+2, vector<vector<vector<int>>>(n+2, vector<vector<int>>(n+2, vector<int>(2, 1e18))));
dp[n+1][0][0][1] = 0;
dp[n+1][0][0][0] = 0;
pair<int,int> punkte;
int res = 0;
for(int c=0; c<n; c++){//Anz Marken
for(int l=n+1; l>0; l--){//linkes Ende -> wo[l]
for(int r=0; r<l; r++){//rechtes Ende
if(dp[l][r][c][0]!=1e18){//sind am linken Ende
//ans rechte Ende laufen
int tmp = r+1;
if(tmp!=l){
int dist = wo[tmp]+laenge-wo[l];
if(dp[l][r][c][0]+dist<=zeit[tmp] && tmp!=0 && tmp!=n+1){
dp[l][tmp][c+1][1] = dp[l][r][c][0] + dist;