#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) ll(x.size())
#define pb push_back
#define N 200005
#define MOD ll(998244353)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
int main()
{
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
vector <pair <int, int> > g; g.clear();
for (int i = 0; i < n; i++) {int x; cin >> x; g.pb({x, 1});}
int m;
cin >> m;
for (int i = 0; i < m; i++) {int x; cin >> x; g.pb({x, 2});}
sort(g.begin(), g.end());
int ans = 0;
int i = 0;
while (i < sz(g) && g[i].F <= 24 * 60) i++;
cout << i << endl;
int lst1 = -1, lst2 = -1;
int a = 0, b = 0;
for (int i = 0; i < sz(g); i++)
{
if (g[i].S == 1) a++; else b++;
if (a > b && lst1 > lst2) ans++;
else if (a < b && lst1 < lst2) ans++;
if (a > b) lst2 = i;
if (a < b) lst1 = i;
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |