#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector<int> cnt_a(2881), cnt_b(2881);
for (int i = 0; i < n; i++) {
int x; cin >> x;
cnt_a[x]++;
}
int m; cin >> m;
for (int i = 0; i < m; i++) {
int x; cin >> x;
cnt_b[x]++;
}
int res2 = 0;
vector<int> lost_a(2881), lost_b(2881);
for (int i = 1; i <= 2880; i++) {
cnt_a[i] += cnt_a[i - 1];
cnt_b[i] += cnt_b[i - 1];
if (cnt_a[i] == cnt_b[i]) {
lost_a[i] = lost_a[i - 1];
lost_b[i] = lost_b[i - 1];
}
else {
lost_a[i] = (cnt_a[i] < cnt_b[i]);
lost_b[i] = (cnt_b[i] < cnt_a[i]);
}
if (lost_a[i - 1] && cnt_a[i] > cnt_b[i]) res2++;
if (lost_b[i - 1] && cnt_b[i] > cnt_a[i]) res2++;
}
int res1 = cnt_a[1440] + cnt_b[1440];
cout << res1 << '\n' << res2 << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
316 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
0 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |