This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, COBOL, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin >> n;
int t[n + 1], h[n + 1];
set<int> st;
for(int i = 1; i <= n; i++){
cin >> h[i];
}
for(int i = 1; i <= n; i++){
cin >> t[i];
st.insert(t[i]);
}
bool bisa[n + 1];
memset(bisa, 0, sizeof(bisa));
if(st.size() == 1){
for(int i = 1; i <= n; i++){
if(h[i] != t[i]){
continue;
}
bisa[i] = true;
int l = i - 1, r = i + 1;
while(l > 0 && h[l] <= t[i] && !bisa[l]){
bisa[l] = true;
l--;
}
while(r <= n && h[r] <= t[i] && !bisa[r]){
bisa[r] = true;
r++;
}
}
}
int cnt = 0;
for(int i = 1; i <= n; i++){
if(bisa[i]){
cnt++;
}
}
cout << cnt << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
while(t--){
solve();
}
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... |