#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<ll> h(n);
vector<ll> t(n);
for(int i = 0 ; i < n ; i++){
cin >> h[i];
}
for(int i = 0 ; i < n ; i++){
cin >> t[i];
}
bool tbeh = 0;
int ta = t[0], l = -1, ans = 0;
for(int i = 0 ; i < n ; i++){
if(h[i] < ta){
if(tbeh){
ans++;
}else if(l == -1){
l = i;
}
}else if( h[i] > ta){
tbeh = 0;
l = -1;
}else{
if( l != -1){
ans += i-l;
}
l = -1;
ans++;
tbeh = 1;
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
596 KB |
Output is correct |
3 |
Correct |
12 ms |
1620 KB |
Output is correct |
4 |
Correct |
8 ms |
1876 KB |
Output is correct |
5 |
Correct |
15 ms |
1876 KB |
Output is correct |
6 |
Correct |
8 ms |
1904 KB |
Output is correct |
7 |
Correct |
11 ms |
1876 KB |
Output is correct |
8 |
Correct |
16 ms |
1876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |