# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
229129 | Vimmer | Preokret (COCI18_preokret) | C++14 | 5 ms | 384 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>
//#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |