제출 #1251078

#제출 시각아이디문제언어결과실행 시간메모리
1251078gry3125Collecting Stamps 3 (JOI20_ho_t3)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long int
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using namespace std;

int main() {
    ll n, l, mx = 0; cin >> n >> l; 
    vector<ll> x(n), t(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> t[i];

    // clockwise 
    ll cur = 0;
    for (int i = 0; i < n; i++) {
        if (t[i] < x[i]) cur++;
    }
    mx = max(mx, n-cur);
    // anticlockwise
    cur = 0;
    for (int i = n-1; i >= 0; i--) {
        if (t[i] < l-x[i]) cur++;
    }
    mx = max(mx, n-cur);
    
    cur = 0; 
    for (int i = 0; i < n; i++) {
    	if (t[i] < x[i]) cur++; ll curr = 0;
    	for (int j = n-1; j > i; j--) {
    		if (t[j] < 2*x[i]+(l-x[j])) curr++;
    		mx = max(mx, n-(j-i)+1-cur-curr);
    	}
    }
    cur = 0;
    for (int i = n-1; i >= 0; i--) {
        if (t[i] < l-x[i]) cur++; ll curr = 0;
        for (int j = 0; j < i; j++) {
        	if (t[j] < 2*(l-x[i])+x[j]) curr++;
        	mx = max(mx, n-(i-j)+1-cur-curr);
        }
    }
    cout << mx;

    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...