# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
120434 | cvele | Preokret (COCI18_preokret) | C++14 | 3 ms | 500 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 <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
using namespace std;
int main() {
vector < pair <int, int> > vec;
int n, m;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
vec.push_back({x, 0});
}
cin >> m;
for (int i = 0; i < m; i++) {
int x;
cin >> x;
vec.push_back({x, 1});
}
sort(vec.begin(), vec.end());
int ans = 0, res = 0;
int lst = -1;
int a = 0, b = 0;
for (int i = 0; i < vec.size(); i++) {
ans += vec[i].first <= 1440;
if (vec[i].second == 0) {
a++;
if (a > b && b > 0 && (lst == -1 || lst == 1)) {
lst = 0;
res++;
}
} else {
b++;
if (b > a && a > 0 && (lst == -1 || lst == 0)) {
lst = 1;
res++;
}
}
}
cout << ans << endl << res << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |