Submission #698614

# Submission time Handle Problem Language Result Execution time Memory
698614 2023-02-14T05:13:53 Z Baytoro Collecting Stamps 3 (JOI20_ho_t3) C++17
25 / 100
2000 ms 218004 KB
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define int long long
#define ll long long
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const ll INF=1e18,mod=1e9+7;
const int N=205;
map<int,int> dp[N][N];
int x[N],t[N];
int n,L,s;
int f(int l, int r){
	if(l>r) swap(l,r);
	return min(r-l,L-r+l);
}
int rec(int i, int j, int time){
	if(abs(i-j)==1) return 0;
	if(dp[i][j].count(time)) return dp[i][j][time];
	int c=i,l=min(i,j),r=max(i,j);
	int ans=rec(l+1,r,min(s,f(x[c],x[l+1])+time))+(f(x[c],x[l+1])+time<=t[l+1]);
	ans=max(ans,rec(r-1,l,min(s,f(x[c],x[r-1])+time))+(f(x[c],x[r-1])+time<=t[r-1]));
	dp[i][j][time]=ans;
	return ans;
}
void solve(){
	cin>>n>>L;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	for(int i=1;i<=n;i++){
		cin>>t[i];
		s=max(s,t[i]+1);
	}
	cout<<rec(0,n+1,0);
}
main(){
	ios;
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}

Compilation message

ho_t3.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main(){
      | ^~~~
ho_t3.cpp: In function 'void fopn(std::string)':
ho_t3.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ho_t3.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 2 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 1 ms 2260 KB Output is correct
7 Correct 2 ms 2292 KB Output is correct
8 Correct 1 ms 2260 KB Output is correct
9 Correct 2 ms 2260 KB Output is correct
10 Correct 1 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 2 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 1 ms 2260 KB Output is correct
7 Correct 2 ms 2292 KB Output is correct
8 Correct 1 ms 2260 KB Output is correct
9 Correct 2 ms 2260 KB Output is correct
10 Correct 1 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
18 Correct 1 ms 2260 KB Output is correct
19 Correct 2 ms 2260 KB Output is correct
20 Correct 1 ms 2260 KB Output is correct
21 Correct 1 ms 2292 KB Output is correct
22 Correct 1 ms 2300 KB Output is correct
23 Correct 11 ms 4308 KB Output is correct
24 Correct 2 ms 2288 KB Output is correct
25 Correct 5 ms 3200 KB Output is correct
26 Correct 2 ms 2260 KB Output is correct
27 Correct 1 ms 2296 KB Output is correct
28 Correct 1 ms 2260 KB Output is correct
29 Correct 1 ms 2260 KB Output is correct
30 Correct 1 ms 2260 KB Output is correct
31 Correct 1 ms 2260 KB Output is correct
32 Correct 1 ms 2288 KB Output is correct
33 Correct 2 ms 2388 KB Output is correct
34 Correct 2 ms 2388 KB Output is correct
35 Correct 2 ms 2388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 2 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 1 ms 2260 KB Output is correct
7 Correct 2 ms 2292 KB Output is correct
8 Correct 1 ms 2260 KB Output is correct
9 Correct 2 ms 2260 KB Output is correct
10 Correct 1 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
18 Correct 252 ms 43316 KB Output is correct
19 Correct 165 ms 32516 KB Output is correct
20 Correct 63 ms 15312 KB Output is correct
21 Correct 140 ms 28196 KB Output is correct
22 Correct 154 ms 29964 KB Output is correct
23 Correct 128 ms 22832 KB Output is correct
24 Correct 2 ms 2684 KB Output is correct
25 Correct 115 ms 22352 KB Output is correct
26 Correct 2 ms 2388 KB Output is correct
27 Correct 113 ms 22804 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 122 ms 23024 KB Output is correct
30 Correct 3 ms 2772 KB Output is correct
31 Correct 111 ms 22216 KB Output is correct
32 Correct 4 ms 3284 KB Output is correct
33 Correct 125 ms 21904 KB Output is correct
34 Correct 2 ms 2420 KB Output is correct
35 Correct 83 ms 18284 KB Output is correct
36 Correct 2 ms 2548 KB Output is correct
37 Correct 99 ms 20104 KB Output is correct
38 Correct 15 ms 6352 KB Output is correct
39 Correct 120 ms 23124 KB Output is correct
40 Correct 2 ms 2644 KB Output is correct
41 Correct 261 ms 44148 KB Output is correct
42 Correct 10 ms 5716 KB Output is correct
43 Correct 242 ms 43668 KB Output is correct
44 Correct 11 ms 6100 KB Output is correct
45 Correct 254 ms 44116 KB Output is correct
46 Correct 10 ms 5972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 2 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 1 ms 2260 KB Output is correct
7 Correct 2 ms 2292 KB Output is correct
8 Correct 1 ms 2260 KB Output is correct
9 Correct 2 ms 2260 KB Output is correct
10 Correct 1 ms 2260 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 1 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
18 Correct 1 ms 2260 KB Output is correct
19 Correct 2 ms 2260 KB Output is correct
20 Correct 1 ms 2260 KB Output is correct
21 Correct 1 ms 2292 KB Output is correct
22 Correct 1 ms 2300 KB Output is correct
23 Correct 11 ms 4308 KB Output is correct
24 Correct 2 ms 2288 KB Output is correct
25 Correct 5 ms 3200 KB Output is correct
26 Correct 2 ms 2260 KB Output is correct
27 Correct 1 ms 2296 KB Output is correct
28 Correct 1 ms 2260 KB Output is correct
29 Correct 1 ms 2260 KB Output is correct
30 Correct 1 ms 2260 KB Output is correct
31 Correct 1 ms 2260 KB Output is correct
32 Correct 1 ms 2288 KB Output is correct
33 Correct 2 ms 2388 KB Output is correct
34 Correct 2 ms 2388 KB Output is correct
35 Correct 2 ms 2388 KB Output is correct
36 Correct 252 ms 43316 KB Output is correct
37 Correct 165 ms 32516 KB Output is correct
38 Correct 63 ms 15312 KB Output is correct
39 Correct 140 ms 28196 KB Output is correct
40 Correct 154 ms 29964 KB Output is correct
41 Correct 128 ms 22832 KB Output is correct
42 Correct 2 ms 2684 KB Output is correct
43 Correct 115 ms 22352 KB Output is correct
44 Correct 2 ms 2388 KB Output is correct
45 Correct 113 ms 22804 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 122 ms 23024 KB Output is correct
48 Correct 3 ms 2772 KB Output is correct
49 Correct 111 ms 22216 KB Output is correct
50 Correct 4 ms 3284 KB Output is correct
51 Correct 125 ms 21904 KB Output is correct
52 Correct 2 ms 2420 KB Output is correct
53 Correct 83 ms 18284 KB Output is correct
54 Correct 2 ms 2548 KB Output is correct
55 Correct 99 ms 20104 KB Output is correct
56 Correct 15 ms 6352 KB Output is correct
57 Correct 120 ms 23124 KB Output is correct
58 Correct 2 ms 2644 KB Output is correct
59 Correct 261 ms 44148 KB Output is correct
60 Correct 10 ms 5716 KB Output is correct
61 Correct 242 ms 43668 KB Output is correct
62 Correct 11 ms 6100 KB Output is correct
63 Correct 254 ms 44116 KB Output is correct
64 Correct 10 ms 5972 KB Output is correct
65 Execution timed out 2093 ms 218004 KB Time limit exceeded
66 Halted 0 ms 0 KB -