//Trương Minh Trí
#include <bits/stdc++.h>
#define FOR(i, x, y) for(int i = x; i <= y; ++i)
#define FORN(i, x, y) for(int i = x; i >= y; --i)
#define Task "Preokret"
#define maxn 3000
#define maxm
#define emlacongchuacuaanh 1302
#define pii pair <int, int>
#define pll pair <long long, long long>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define reset(x) memset(x, 0, sizeof(x));
using namespace std;
int n, m;
int res1, res2;
pii a[maxn], b[maxn];
int scoreA, scoreB;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
//freopen(Task".inp", "r", stdin);
//freopen(Task".out", "w", stdout);
cin >> n;
FOR(i, 1, n) cin >> a[i].F, a[i].S = 1;
cin >> m;
FOR(i, 1, m) cin >> b[i].F, b[i].S = 2;
FOR(i, 1, n) if(a[i].F <= 1440) res1++;
FOR(i, 1, m) if(b[i].F <= 1440) res1++;
cout << res1 << "\n";
FOR(i, n+1, m+n) a[i] = b[i-n];
sort(a+1, a+n+m+1);
int A = 0, B = 0;
FOR(i, 1, m+n)
{
if(a[i].S == 1) scoreA++;
else scoreB++;
if(scoreA > scoreB && A < B)
res2++;
else if(scoreB > scoreA && A > B)
res2++;
if(scoreA > scoreB) A = 1, B = 0;
else if(scoreA < scoreB) A = 0, B = 1;
}
cout << res2;
}
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
2 ms |
572 KB |
Output is correct |
5 |
Correct |
2 ms |
572 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
2 ms |
600 KB |
Output is correct |
8 |
Correct |
2 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
2 ms |
632 KB |
Output is correct |