# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259682 | arnold518 | Worst Reporter 2 (JOI16_worst_reporter2) | C++14 | 3 ms | 4992 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 = 2e5;
int N;
pii A[MAXN+10], B[MAXN+10];
vector<int> V[MAXN+10];
int cnt[MAXN+10], P[MAXN+10];
int main()
{
scanf("%d", &N);
for(int i=1; i<=N; i++) scanf("%d%d", &A[i].second, &A[i].first);
for(int i=1; i<=N; i++) scanf("%d%d", &B[i].second, &B[i].first);
sort(A+1, A+N+1);
sort(B+1, B+N+1);
for(int i=1, j=1; i<=N; i++)
{
for(; j<=N && A[j].first<=B[i].first; j++) V[i].push_back(A[j].second);
P[i]=B[i].second;
}
int ans=0;
for(int i=0; i<(1<<N); i++)
{
for(int j=1; j<=N; j++) cnt[j]=0;
bool flag=true;
for(int j=1; j<=N; j++)
{
for(auto it : V[j]) cnt[it]++;
if(i&(1<<(j-1)))
{
if(cnt[P[j]]==0) flag=false;
cnt[P[j]]--;
}
}
if(flag) ans=max(ans, __builtin_popcount(i));
}
printf("%d\n", 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... |