This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(maxx, h[i]);
        } else {
            for (int j = l; j < i; j++) {
                h[j] = maxx;
            }
            maxx = 0;
            l = i + 1;
        }
    }
    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 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... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |