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 <iostream>
using namespace std;
int n;
int a[101010];
int b[101010];
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> b[i];
int last = 1;
int mx = 0;
int ans = 0;
for (int i = 1; i <= n; i++) {
if (a[i] > b[i]) {
if (mx == b[i])
ans += (i - last);
last = i + 1;
mx = 0;
continue;
}
mx = max(mx, a[i]);
continue;
}
if (mx == b[n])
ans += (n - last + 1);
cout << ans;
}
# | 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... |