답안 #827474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827474 2023-08-16T13:52:12 Z Hakiers Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
0 ms 212 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -