# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384713 | AdiZer0 | Preokret (COCI18_preokret) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define whole(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
const ll linf = (ll)1e18 + 1;
int n, a[N];
int m, b[N];
int main() {
scanf ("%d", &n);
for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
scanf ("%d", &m);
for (int i = 1; i <= m; ++i) scanf ("%d", b + i);
int who = -1, p1 = 1;
int half = 0, turn = 0;
int numA = 0, numB = 0;
b[m + 1] = INF:
for (int i = 1; i <= n;) {
if (a[i] < b[p1]) {
if (a[i] <= 1440) ++half;
numA++;
++i;
} else {
if (b[p1] <= 1440) ++half;
numB++;
++p1;
}
if (who == -1) {
if (numA > numB) who = 0;
else who = 1;
} else {
if (who) {
if (numA > numB) who = 0, ++turn;
} else {
if (numA < numB) who = 1, ++turn;
}
}
}
while (p1 <= m) {
++numB;
if (b[p1] <= 1440) ++half;
if (who == -1) {
if (numA > numB) who = 0;
else who = 1;
} else {
if (who) {
if (numA > numB) who = 0, ++turn;
} else {
if (numA < numB) who = 1, ++turn;
}
}
++p1;
}
printf ("%d\n%d\n", half, turn);
return 0;
}
/*
6
15 30 35 55 60 2065
7
20 25 40 45 50 2070 2075
*/