#include <bits/stdc++.h>
using namespace std;
#ifdef MIKU
#define debug(x...) cout << '[' << #x << "] : ", dout(x)
void dout() { cout << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
int n, m, br;
vector<pii> v;
int s1, s2;
int a1, a2;
void miku() {
cin >> n;
while (n--) {
cin >> br;
v.push_back(mp(br, 1LL));
}
cin >> m;
while (m--) {
cin >> br;
v.push_back(mp(br, 2LL));
}
sort(v.begin(), v.end());
n = v.size();
for (int i = 0, j = 0; i < n; i = j) {
while (j < n && v[i].sc == v[j].sc) j++;
bool f = (v[i].sc == 1 ? (s1 < s2) : (s1 > s2));
FOR(k, i, j) {
if (v[k].fs <= 1440) a1++;
(v[k].sc == 1 ? s1 : s2)++;
}
f &= (v[i].sc == 1 ? (s1 > s2) : (s1 < s2));
if (f) a2++;
}
cout << a1 << '\n' << a2 << '\n';
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(iostream::failbit);
miku();
return 0;
}
# |
Verdict |
Execution time |
Memory |
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 |
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 |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |