# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
329873 | arnold518 | Worst Reporter 2 (JOI16_worst_reporter2) | C++14 | 2076 ms | 25564 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>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 4e5;
int N;
pii _A[MAXN+10];
int A[MAXN+10];
int B[MAXN+10];
vector<int> V[MAXN+10];
int main()
{
scanf("%d", &N);
for(int i=1; i<=N; i++) scanf("%d%d", &_A[i].second, &_A[i].first), _A[i].second*=-1;
for(int i=1; i<=N; i++) scanf("%d%d", &_A[i+N].second, &_A[i+N].first);
N*=2;
sort(_A+1, _A+N+1);
for(int i=1; i<=N; i++) A[i]=_A[i].second;
for(int i=1; i<=N; i++)
{
if(A[i]<0) B[i]=B[i-1]+1;
else B[i]=B[i-1]-1;
}
int ans=N/2;
for(int i=1; i<=N; i++)
{
if(A[i]<0)
{
V[-A[i]].push_back(i);
}
else
{
if(V[A[i]].empty()) continue;
bool flag=true;
for(int j=V[A[i]].back(); j<i; j++)
{
if(B[j]<1) flag=false;
}
if(!flag)
{
V[A[i]].clear();
}
else
{
for(int j=V[A[i]].back(); j<i; j++)
{
B[j]--;
}
V[A[i]].pop_back();
ans--;
}
}
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |