#include "bits/stdc++.h"
using namespace std;
//~ #define int long long
void solve1(int n){
vector<int> a(n), b(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>b[i];
vector<int> dp(n);
if(n <= 200){
} else {
}
}
void solve2(int n){
vector<int> a(n), b(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>b[i];
int last = 0, cnt = 0, res = 0;
for(int i=0;i<n;i++){
if(a[i] > b[0]){
if(cnt){
res += (i - last);
}
cnt = 0, last = i + 1;
} else {
cnt |= (a[i] == b[i]);
}
} if(cnt){
res += (n - last);
}
cout<<res<<"\n";
}
void solve(){
int n; cin>>n;
//~ if(n <= 5005){
//~ solve1(n);
//~ } else {
solve2(n);
//~ }
}
/*
3
1 2 3
2 2 2
*/
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int t = 1;
//~ cin>>t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
7 ms |
844 KB |
Output is correct |
3 |
Correct |
18 ms |
1996 KB |
Output is correct |
4 |
Correct |
15 ms |
1476 KB |
Output is correct |
5 |
Correct |
30 ms |
3140 KB |
Output is correct |
6 |
Correct |
15 ms |
1476 KB |
Output is correct |
7 |
Correct |
16 ms |
1612 KB |
Output is correct |
8 |
Correct |
40 ms |
2988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |