제출 #833313

#제출 시각아이디문제언어결과실행 시간메모리
833313vjudge1Exam (eJOI20_exam)C++17
12 / 100
17 ms1108 KiB
#include <bits/stdc++.h>
using namespace std;

int n;
int h[100005];
int t[100005];

void dua() {
    int l = 0, maxx = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] <= t[0]) {
            maxx = max(h[i], maxx);
        } else {
            for (int j = l; j < i; j++) {
                h[j] = maxx;
            }
            maxx = 0;
            l = i + 1;
        }
    }
    for (int j = l; j < n; j++) {
        h[j] = maxx;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] == t[i]) {
            ans++;
        }
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }

    /*
    // subtask 2
    bool two = 1;
    for (int i = 1; i < n; i++) {
        if (t[i] != t[i-1]) {
            two = 0;
            break;
        }
    }
    if (two) {
        dua();
        return 0;
    }
    */
    dua();

    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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...