Submission #856644

# Submission time Handle Problem Language Result Execution time Memory
856644 2023-10-04T07:16:31 Z 8pete8 Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
113 ms 130952 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
//#include "combo.h"
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define pb push_back
#define p push
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int inf=1e9;
int dp[202][202][202][2],n,m;
int memo[202][202];
//at l r taken ,min time
int caldist(int u,int v){
    //dist u->v;
    if(u>v)swap(v,u);
    if(memo[u][v]!=-1)return memo[u][v];
    return memo[u][v]=min((v-u),m-v+u);
}
int32_t main(){
    cin>>n>>m;
    n++;
    vector<pii>v(n);
    v[0].f=0,v[0].s=0;
    for(int i=1;i<n;i++)cin>>v[i].f;
    for(int i=1;i<n;i++)cin>>v[i].s;
    for(int i=0;i<=200;i++)for(int j=0;j<=200;j++){
        memo[i][j]=-1;
        for(int k=0;k<=200;k++)dp[i][j][k][0]=dp[i][j][k][1]=inf;
    }
    dp[0][0][0][0]=dp[0][0][0][1]=0;
    for(int sz=0;sz<n-1;sz++){
        int l,r=0,nr,nl;
        l=(n-sz)%n;
        bool yes=true;
        while(yes){
            if(l==0)yes=false;
            nr=(r+1)%n;
            nl=(l-1+n)%n;
            for(int t=0;t<=n;t++){
                if(dp[l][r][t][0]+caldist(v[nr].f,v[l].f)<=v[nr].s)dp[l][nr][t+1][1]=min(dp[l][nr][t+1][1],dp[l][r][t][0]+caldist(v[nr].f,v[l].f));
                else dp[l][nr][t][1]=min(dp[l][nr][t][1],dp[l][r][t][0]+caldist(v[nr].f,v[l].f));//l to nr
                if(dp[l][r][t][0]+caldist(v[l].f,v[nl].f)<=v[nl].s)dp[nl][r][t+1][0]=min(dp[nl][r][t+1][0],dp[l][r][t][0]+caldist(v[l].f,v[nl].f));
                else dp[nl][r][t][0]=min(dp[nl][r][t][0],dp[l][r][t][0]+caldist(v[l].f,v[nl].f));
                if(dp[l][r][t][1]+caldist(v[r].f,v[nl].f)<=v[nl].s)dp[nl][r][t+1][0]=min(dp[nl][r][t+1][0],dp[l][r][t][1]+caldist(v[r].f,v[nl].f));
                else dp[nl][r][t][0]=min(dp[nl][r][t][0],dp[l][r][t][1]+caldist(v[r].f,v[nl].f));
                if(dp[l][r][t][1]+caldist(v[nr].f,v[r].f)<=v[nr].s)dp[l][nr][t+1][1]=min(dp[l][nr][t+1][1],dp[l][r][t][1]+caldist(v[nr].f,v[r].f));
                else dp[l][nr][t][1]=min(dp[l][nr][t][1],dp[l][r][t][1]+caldist(v[nr].f,v[r].f));
            }
            r=nr;
            l=(l+1)%n;
        }
    }
    int ans=0;
    for(int i=0;i<=200;i++)for(int j=0;j<=200;j++)for(int k=0;k<=200;k++)for(int g=0;g<2;g++)if(dp[i][j][k][g]<inf)ans=max(ans,k);
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 20 ms 64800 KB Output is correct
2 Correct 20 ms 64800 KB Output is correct
3 Correct 20 ms 64604 KB Output is correct
4 Correct 20 ms 64604 KB Output is correct
5 Correct 21 ms 64672 KB Output is correct
6 Correct 20 ms 64604 KB Output is correct
7 Correct 19 ms 64600 KB Output is correct
8 Correct 21 ms 64680 KB Output is correct
9 Correct 20 ms 64604 KB Output is correct
10 Correct 22 ms 64800 KB Output is correct
11 Correct 22 ms 64584 KB Output is correct
12 Correct 21 ms 64604 KB Output is correct
13 Correct 27 ms 64600 KB Output is correct
14 Correct 20 ms 64604 KB Output is correct
15 Correct 20 ms 64800 KB Output is correct
16 Correct 20 ms 64604 KB Output is correct
17 Correct 20 ms 64604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 64800 KB Output is correct
2 Correct 20 ms 64800 KB Output is correct
3 Correct 20 ms 64604 KB Output is correct
4 Correct 20 ms 64604 KB Output is correct
5 Correct 21 ms 64672 KB Output is correct
6 Correct 20 ms 64604 KB Output is correct
7 Correct 19 ms 64600 KB Output is correct
8 Correct 21 ms 64680 KB Output is correct
9 Correct 20 ms 64604 KB Output is correct
10 Correct 22 ms 64800 KB Output is correct
11 Correct 22 ms 64584 KB Output is correct
12 Correct 21 ms 64604 KB Output is correct
13 Correct 27 ms 64600 KB Output is correct
14 Correct 20 ms 64604 KB Output is correct
15 Correct 20 ms 64800 KB Output is correct
16 Correct 20 ms 64604 KB Output is correct
17 Correct 20 ms 64604 KB Output is correct
18 Runtime error 61 ms 130952 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 64800 KB Output is correct
2 Correct 20 ms 64800 KB Output is correct
3 Correct 20 ms 64604 KB Output is correct
4 Correct 20 ms 64604 KB Output is correct
5 Correct 21 ms 64672 KB Output is correct
6 Correct 20 ms 64604 KB Output is correct
7 Correct 19 ms 64600 KB Output is correct
8 Correct 21 ms 64680 KB Output is correct
9 Correct 20 ms 64604 KB Output is correct
10 Correct 22 ms 64800 KB Output is correct
11 Correct 22 ms 64584 KB Output is correct
12 Correct 21 ms 64604 KB Output is correct
13 Correct 27 ms 64600 KB Output is correct
14 Correct 20 ms 64604 KB Output is correct
15 Correct 20 ms 64800 KB Output is correct
16 Correct 20 ms 64604 KB Output is correct
17 Correct 20 ms 64604 KB Output is correct
18 Correct 88 ms 64600 KB Output is correct
19 Correct 53 ms 64604 KB Output is correct
20 Correct 33 ms 64604 KB Output is correct
21 Correct 51 ms 64692 KB Output is correct
22 Correct 64 ms 64700 KB Output is correct
23 Correct 30 ms 64600 KB Output is correct
24 Correct 27 ms 64856 KB Output is correct
25 Correct 30 ms 64604 KB Output is correct
26 Correct 22 ms 64600 KB Output is correct
27 Correct 32 ms 64604 KB Output is correct
28 Correct 32 ms 64616 KB Output is correct
29 Correct 34 ms 64600 KB Output is correct
30 Correct 28 ms 64604 KB Output is correct
31 Correct 30 ms 64604 KB Output is correct
32 Correct 24 ms 64604 KB Output is correct
33 Correct 30 ms 64604 KB Output is correct
34 Correct 22 ms 64604 KB Output is correct
35 Correct 30 ms 64596 KB Output is correct
36 Correct 25 ms 64604 KB Output is correct
37 Correct 35 ms 64604 KB Output is correct
38 Correct 28 ms 64604 KB Output is correct
39 Correct 35 ms 64860 KB Output is correct
40 Correct 25 ms 64600 KB Output is correct
41 Correct 113 ms 64600 KB Output is correct
42 Correct 71 ms 64604 KB Output is correct
43 Correct 113 ms 64604 KB Output is correct
44 Correct 78 ms 64848 KB Output is correct
45 Correct 110 ms 64780 KB Output is correct
46 Correct 72 ms 64776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 64800 KB Output is correct
2 Correct 20 ms 64800 KB Output is correct
3 Correct 20 ms 64604 KB Output is correct
4 Correct 20 ms 64604 KB Output is correct
5 Correct 21 ms 64672 KB Output is correct
6 Correct 20 ms 64604 KB Output is correct
7 Correct 19 ms 64600 KB Output is correct
8 Correct 21 ms 64680 KB Output is correct
9 Correct 20 ms 64604 KB Output is correct
10 Correct 22 ms 64800 KB Output is correct
11 Correct 22 ms 64584 KB Output is correct
12 Correct 21 ms 64604 KB Output is correct
13 Correct 27 ms 64600 KB Output is correct
14 Correct 20 ms 64604 KB Output is correct
15 Correct 20 ms 64800 KB Output is correct
16 Correct 20 ms 64604 KB Output is correct
17 Correct 20 ms 64604 KB Output is correct
18 Runtime error 61 ms 130952 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -