/******************************************************************************
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
596 KB |
Output is correct |
3 |
Correct |
11 ms |
1240 KB |
Output is correct |
4 |
Correct |
9 ms |
1236 KB |
Output is correct |
5 |
Correct |
18 ms |
1308 KB |
Output is correct |
6 |
Correct |
10 ms |
1196 KB |
Output is correct |
7 |
Correct |
10 ms |
1260 KB |
Output is correct |
8 |
Correct |
17 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |