제출 #352668

#제출 시각아이디문제언어결과실행 시간메모리
352668mariowongCollecting Stamps 3 (JOI20_ho_t3)C++14
0 / 100
1 ms364 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...