Submission #827474

#TimeUsernameProblemLanguageResultExecution timeMemory
827474HakiersCollecting Stamps 3 (JOI20_ho_t3)C++17
0 / 100
0 ms212 KiB
#include <iostream>
#include <math.h>
using namespace std;
const int MAXN = 1e3;
pair<int, int> t[MAXN];
int best;
int n, l;

void left(){
    int act = 0;
    for(int i = 1; i <= n; i++){
        
        int tajm = t[i].first;
        if(t[i].second >= tajm)
            act += 1;

        int j = n;
        int atmp = 0;
        while(j > i){
            int tmp = abs(l - t[j].first);
            if(t[j].second >= tmp + 2*tajm)
                atmp++;
            j--;
        }

        best = max(best, act + atmp);

    }
}

void right(){
    int act = 0;
    for(int i = n; i >=1; i--){
        
        int tajm = abs(l - t[i].first);
        if(t[i].second >= tajm)
            act += 1;

        int j = 1;
        int atmp = 0;
        while(j < i){
            int tmp = t[j].first;
            if(t[j].second >= tmp + 2*tajm)
                atmp++;
            j++;
        }

        best = max(best, act + atmp);

    }
}

int main(){
    ios_base::sync_with_stdio();
    cin.tie(0);
    cin >> n >> l;
    for(int i = 1; i <= n; i++)
        cin >> t[i].first;
    for(int i = 1; i <= n; i++)
        cin >> t[i].second;

    left();
    right();

    cout << best << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...