#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int main()
{
ll n;
cin >> n;
vector<ll> slots(n);
vector<ll> users(n);
for (ll i = 0; i < n; i++)
{
cin >> slots[i];
}
for (ll i = 0; i < n; i++)
{
cin >> users[i];
}
ll happy = 0;
ll wanting = 0;
ll satisfiable = 0;
for(int i = n-1; i >= 0; i--){
if(slots[i]){
if(wanting>0){
wanting--;
happy++;
slots[i]=0;
}else if (satisfiable>0){
satisfiable--;
happy++;
slots[i]=0;
}
}
if(users[i]&&!slots[i]) wanting++;
if(slots[i]&&users[i]) satisfiable++;
}
cout << happy-wanting;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
40 ms |
4956 KB |
Output is correct |
3 |
Correct |
43 ms |
5208 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
44 ms |
5848 KB |
Output is correct |
11 |
Correct |
44 ms |
5968 KB |
Output is correct |
12 |
Correct |
46 ms |
5880 KB |
Output is correct |
13 |
Correct |
44 ms |
5716 KB |
Output is correct |
14 |
Correct |
40 ms |
5660 KB |
Output is correct |
15 |
Correct |
40 ms |
5716 KB |
Output is correct |
16 |
Correct |
45 ms |
5676 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |