이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define int long long
const int maxn = 5e5+10;
const ll inf = 1e18+10;
int n, L;
int x[maxn], t[maxn];
signed main()
{
    cin>> n >> L;
    for(int i = 1; i <= n; i++) cin>> x[i];
    for(int i = 1; i <= n; i++) cin>> t[i];
    ll ans = 0;
    for(int l = 0; l <= n; l++)
        for(int R = l+1; R <= n+1; R++)
        {
            int r = R;
            int A = 0, tim = 0;
            for(int i = 1; i <= l; i++)
                if(tim + x[i] <= t[i])
                    A++;
            ans = max(ans,A);
            tim = 2*x[l];
            for(int i = n; i >= r; i--)
                if(tim + (L-x[i]) <= t[i])
                    A++;
            ans = max(ans,A);
            A = 0, tim = 2*(L-x[r]);
            if(r == n+1) tim = 0;
            for(int i = 1; i <= l; i++)
                if(tim + x[i] <= t[i])
                    A++;
            ans = max(ans,A);
            tim = 0;
            for(int i = n; i >= r; i--)
                if(tim + (L-x[i]) <= t[i])
                    A++;
            ans = max(ans,A);
        }
    cout<< ans;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |