답안 #698064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698064 2023-02-12T07:43:34 Z myrcella Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
91 ms 86080 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
void MIN(int &a,int b) {
	if (a==-1) a = b;
	else a = min(a,b);
}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const int maxn = 222;
int n,len;
int pos[maxn];
int dp[maxn][maxn][maxn][2];
int t[maxn];
int big;
int ans = 0;

int main() {
//	freopen("input.txt","r",stdin);	
	std::ios::sync_with_stdio(false);cin.tie(0);
	memset(dp,-1,sizeof(dp));
	dp[0][0][0][0] = dp[0][0][0][1] = 0;
	cin>>n>>len;
	pos[0] = 0,pos[n+1] = len;
	rep(i,1,n+1) cin>>pos[i];
	rep(i,1,n+1) cin>>t[i];
	rep(i,0,n+1)
		rep(j,0,n-i+1)
			rep(k,0,i+j+1) {
//				cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k][0]<<" "<<dp[i][j][k][1]<<endl;
				if (dp[i][j][k][0]!=-1) {
					ans = max(ans,k);
					int tn = min(mod,dp[i][j][k][0] + pos[i+1]-pos[i]);
//					debug(tn);
					MIN(dp[i+1][j][k+(tn<=t[i+1])][0],tn);
					tn = min(mod,dp[i][j][k][0] + pos[i] + len-pos[n-j]);
//					debug(tn);
					MIN(dp[i][j+1][k+(tn<=t[n-j])][1],tn);
				}
				if (dp[i][j][k][1]!=-1) {
					ans = max(ans,k);
					int tn = min(mod,dp[i][j][k][1] + pos[n-j+1] - pos[n-j]);
//					debug(tn);
					MIN(dp[i][j+1][k+(tn<=t[n-j])][1],tn);
					tn = min(mod,dp[i][j][k][1] + len-pos[n-j+1] + pos[i+1]);
//					debug(tn);
					MIN(dp[i+1][j][k+(tn<=t[i+1])][0],tn);
				}
			}
	cout<<ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 85836 KB Output is correct
2 Correct 32 ms 85860 KB Output is correct
3 Correct 35 ms 85876 KB Output is correct
4 Correct 37 ms 85836 KB Output is correct
5 Correct 36 ms 85844 KB Output is correct
6 Correct 34 ms 85836 KB Output is correct
7 Correct 32 ms 85912 KB Output is correct
8 Correct 32 ms 85912 KB Output is correct
9 Correct 33 ms 85920 KB Output is correct
10 Correct 34 ms 85912 KB Output is correct
11 Correct 32 ms 85864 KB Output is correct
12 Correct 33 ms 85828 KB Output is correct
13 Correct 32 ms 85848 KB Output is correct
14 Correct 32 ms 85836 KB Output is correct
15 Correct 33 ms 85904 KB Output is correct
16 Correct 34 ms 85844 KB Output is correct
17 Correct 34 ms 85908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 85836 KB Output is correct
2 Correct 32 ms 85860 KB Output is correct
3 Correct 35 ms 85876 KB Output is correct
4 Correct 37 ms 85836 KB Output is correct
5 Correct 36 ms 85844 KB Output is correct
6 Correct 34 ms 85836 KB Output is correct
7 Correct 32 ms 85912 KB Output is correct
8 Correct 32 ms 85912 KB Output is correct
9 Correct 33 ms 85920 KB Output is correct
10 Correct 34 ms 85912 KB Output is correct
11 Correct 32 ms 85864 KB Output is correct
12 Correct 33 ms 85828 KB Output is correct
13 Correct 32 ms 85848 KB Output is correct
14 Correct 32 ms 85836 KB Output is correct
15 Correct 33 ms 85904 KB Output is correct
16 Correct 34 ms 85844 KB Output is correct
17 Correct 34 ms 85908 KB Output is correct
18 Correct 32 ms 85864 KB Output is correct
19 Correct 37 ms 85860 KB Output is correct
20 Correct 34 ms 85924 KB Output is correct
21 Correct 34 ms 85852 KB Output is correct
22 Correct 34 ms 85880 KB Output is correct
23 Correct 34 ms 85844 KB Output is correct
24 Correct 37 ms 85852 KB Output is correct
25 Correct 33 ms 85836 KB Output is correct
26 Correct 35 ms 85956 KB Output is correct
27 Correct 36 ms 85968 KB Output is correct
28 Correct 38 ms 85824 KB Output is correct
29 Correct 33 ms 85900 KB Output is correct
30 Correct 35 ms 85908 KB Output is correct
31 Correct 32 ms 85908 KB Output is correct
32 Correct 32 ms 85936 KB Output is correct
33 Correct 34 ms 85936 KB Output is correct
34 Correct 32 ms 85828 KB Output is correct
35 Correct 38 ms 85944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 85836 KB Output is correct
2 Correct 32 ms 85860 KB Output is correct
3 Correct 35 ms 85876 KB Output is correct
4 Correct 37 ms 85836 KB Output is correct
5 Correct 36 ms 85844 KB Output is correct
6 Correct 34 ms 85836 KB Output is correct
7 Correct 32 ms 85912 KB Output is correct
8 Correct 32 ms 85912 KB Output is correct
9 Correct 33 ms 85920 KB Output is correct
10 Correct 34 ms 85912 KB Output is correct
11 Correct 32 ms 85864 KB Output is correct
12 Correct 33 ms 85828 KB Output is correct
13 Correct 32 ms 85848 KB Output is correct
14 Correct 32 ms 85836 KB Output is correct
15 Correct 33 ms 85904 KB Output is correct
16 Correct 34 ms 85844 KB Output is correct
17 Correct 34 ms 85908 KB Output is correct
18 Correct 62 ms 85844 KB Output is correct
19 Correct 47 ms 85832 KB Output is correct
20 Correct 35 ms 85836 KB Output is correct
21 Correct 44 ms 85848 KB Output is correct
22 Correct 52 ms 85940 KB Output is correct
23 Correct 39 ms 85912 KB Output is correct
24 Correct 33 ms 85872 KB Output is correct
25 Correct 41 ms 85836 KB Output is correct
26 Correct 40 ms 85900 KB Output is correct
27 Correct 45 ms 85856 KB Output is correct
28 Correct 34 ms 85876 KB Output is correct
29 Correct 39 ms 85892 KB Output is correct
30 Correct 39 ms 85924 KB Output is correct
31 Correct 42 ms 85844 KB Output is correct
32 Correct 34 ms 85872 KB Output is correct
33 Correct 37 ms 85944 KB Output is correct
34 Correct 33 ms 85844 KB Output is correct
35 Correct 36 ms 85972 KB Output is correct
36 Correct 35 ms 85944 KB Output is correct
37 Correct 39 ms 85928 KB Output is correct
38 Correct 32 ms 85880 KB Output is correct
39 Correct 34 ms 85844 KB Output is correct
40 Correct 34 ms 85856 KB Output is correct
41 Correct 69 ms 85868 KB Output is correct
42 Correct 36 ms 85836 KB Output is correct
43 Correct 68 ms 85852 KB Output is correct
44 Correct 34 ms 85828 KB Output is correct
45 Correct 76 ms 85868 KB Output is correct
46 Correct 41 ms 85836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 85836 KB Output is correct
2 Correct 32 ms 85860 KB Output is correct
3 Correct 35 ms 85876 KB Output is correct
4 Correct 37 ms 85836 KB Output is correct
5 Correct 36 ms 85844 KB Output is correct
6 Correct 34 ms 85836 KB Output is correct
7 Correct 32 ms 85912 KB Output is correct
8 Correct 32 ms 85912 KB Output is correct
9 Correct 33 ms 85920 KB Output is correct
10 Correct 34 ms 85912 KB Output is correct
11 Correct 32 ms 85864 KB Output is correct
12 Correct 33 ms 85828 KB Output is correct
13 Correct 32 ms 85848 KB Output is correct
14 Correct 32 ms 85836 KB Output is correct
15 Correct 33 ms 85904 KB Output is correct
16 Correct 34 ms 85844 KB Output is correct
17 Correct 34 ms 85908 KB Output is correct
18 Correct 32 ms 85864 KB Output is correct
19 Correct 37 ms 85860 KB Output is correct
20 Correct 34 ms 85924 KB Output is correct
21 Correct 34 ms 85852 KB Output is correct
22 Correct 34 ms 85880 KB Output is correct
23 Correct 34 ms 85844 KB Output is correct
24 Correct 37 ms 85852 KB Output is correct
25 Correct 33 ms 85836 KB Output is correct
26 Correct 35 ms 85956 KB Output is correct
27 Correct 36 ms 85968 KB Output is correct
28 Correct 38 ms 85824 KB Output is correct
29 Correct 33 ms 85900 KB Output is correct
30 Correct 35 ms 85908 KB Output is correct
31 Correct 32 ms 85908 KB Output is correct
32 Correct 32 ms 85936 KB Output is correct
33 Correct 34 ms 85936 KB Output is correct
34 Correct 32 ms 85828 KB Output is correct
35 Correct 38 ms 85944 KB Output is correct
36 Correct 62 ms 85844 KB Output is correct
37 Correct 47 ms 85832 KB Output is correct
38 Correct 35 ms 85836 KB Output is correct
39 Correct 44 ms 85848 KB Output is correct
40 Correct 52 ms 85940 KB Output is correct
41 Correct 39 ms 85912 KB Output is correct
42 Correct 33 ms 85872 KB Output is correct
43 Correct 41 ms 85836 KB Output is correct
44 Correct 40 ms 85900 KB Output is correct
45 Correct 45 ms 85856 KB Output is correct
46 Correct 34 ms 85876 KB Output is correct
47 Correct 39 ms 85892 KB Output is correct
48 Correct 39 ms 85924 KB Output is correct
49 Correct 42 ms 85844 KB Output is correct
50 Correct 34 ms 85872 KB Output is correct
51 Correct 37 ms 85944 KB Output is correct
52 Correct 33 ms 85844 KB Output is correct
53 Correct 36 ms 85972 KB Output is correct
54 Correct 35 ms 85944 KB Output is correct
55 Correct 39 ms 85928 KB Output is correct
56 Correct 32 ms 85880 KB Output is correct
57 Correct 34 ms 85844 KB Output is correct
58 Correct 34 ms 85856 KB Output is correct
59 Correct 69 ms 85868 KB Output is correct
60 Correct 36 ms 85836 KB Output is correct
61 Correct 68 ms 85852 KB Output is correct
62 Correct 34 ms 85828 KB Output is correct
63 Correct 76 ms 85868 KB Output is correct
64 Correct 41 ms 85836 KB Output is correct
65 Correct 65 ms 85948 KB Output is correct
66 Correct 62 ms 85836 KB Output is correct
67 Correct 66 ms 85948 KB Output is correct
68 Correct 56 ms 85928 KB Output is correct
69 Correct 68 ms 85836 KB Output is correct
70 Correct 73 ms 85960 KB Output is correct
71 Correct 64 ms 85836 KB Output is correct
72 Correct 77 ms 85836 KB Output is correct
73 Correct 50 ms 85952 KB Output is correct
74 Correct 63 ms 85952 KB Output is correct
75 Correct 64 ms 85956 KB Output is correct
76 Correct 65 ms 85984 KB Output is correct
77 Correct 69 ms 85956 KB Output is correct
78 Correct 63 ms 85884 KB Output is correct
79 Correct 59 ms 85836 KB Output is correct
80 Correct 74 ms 85960 KB Output is correct
81 Correct 61 ms 85836 KB Output is correct
82 Correct 54 ms 85968 KB Output is correct
83 Correct 67 ms 85876 KB Output is correct
84 Correct 52 ms 85840 KB Output is correct
85 Correct 59 ms 85856 KB Output is correct
86 Correct 54 ms 85844 KB Output is correct
87 Correct 63 ms 85944 KB Output is correct
88 Correct 91 ms 86080 KB Output is correct
89 Correct 64 ms 85952 KB Output is correct
90 Correct 44 ms 85836 KB Output is correct
91 Correct 84 ms 85948 KB Output is correct
92 Correct 73 ms 85956 KB Output is correct
93 Correct 45 ms 85840 KB Output is correct