Submission #352668

# Submission time Handle Problem Language Result Execution time Memory
352668 2021-01-21T03:46:26 Z mariowong Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7) 
#define hmod 1286031825167LL
using namespace std;

ll n,l,used,ct,ans;
pll a[205];
ll left(ll x){
	ct=0; used=0;
	for (int i=n;i>=n-x+1;i--){
		used+=a[i+1].x-a[i].x;
		if (used <= a[i].y)
		ct++;
	}
	used+=l-a[n-x+1].x;
	for (int i=1;i<=n-x;i++){
		used+=a[i].x-a[i-1].x;
		if (used <= a[i].y)
		ct++;
	}
	return ct;
}
ll right(ll x){
	ct=0; used=0;
	for (int i=1;i<=x;i++){
		used+=a[i].x-a[i-1].x;
		if (used <= a[i].y)
		ct++;
	}
	used+=a[x].x;
	for (int i=n;i>=x+1;i--){
		used+=a[i+1].x-a[i].x;
		if (used <= a[i].y)
		ct++;
	}
	return ct;
}
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> l;
	for (int i=1;i<=n;i++){
		cin >> a[i].x;
	}
	for (int i=1;i<=n;i++){
		cin >> a[i].y;
	}
	a[n+1].x=l;
	for (int i=0;i<=n;i++){
		ans=max(ans,left(i));
		ans=max(ans,right(i));
	}
	cout << ans << "\n";
    return 0;	
}	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -