Submission #910262

# Submission time Handle Problem Language Result Execution time Memory
910262 2024-01-18T03:22:19 Z bachhoangxuan None (JOI16_worst_reporter2) C++17
100 / 100
208 ms 50000 KB
// Judges with GCC >= 12 only needs Ofast
// #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize")
// MLE optimization
// #pragma GCC optimize("conserve-stack")
// Old judges
// #pragma GCC target("sse4.2,popcnt,lzcnt,abm,mmx,fma,bmi,bmi2")
// New judges. Test with assert(__builtin_cpu_supports("avx2"));
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
// Atcoder
// #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma")
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
- insert(x),erase(x)
- find_by_order(k): return iterator to the k-th smallest element
- order_of_key(x): the number of elements that are strictly smaller
*/

#include<bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_real_distribution<> pp(0.0,1.0);
#define int long long
#define ld long double
#define pii pair<int,int>
#define piii pair<int,pii>
#define mpp make_pair
#define fi first
#define se second
const int inf=1e18;
const int mod=998244353;
const int maxn=200005;
const int bl=650;
const int maxs=655;
const int maxm=200005;
const int maxq=1000005;
const int maxl=25;
const int maxa=1000000;
const int root=3;
int power(int a,int n){
    int res=1;
    while(n){
        if(n&1) res=res*a%mod;
        a=a*a%mod;n>>=1;
    }
    return res;
}
const int iroot=power(3,mod-2);
const int base=131;

pii p[2*maxn];
int cnt[2*maxn];
int n,a[maxn],b[maxn],c[maxn],d[maxn];
vector<int> q[maxn];

int tree[8*maxn],lazy[8*maxn];
void build(int l,int r,int id){
    if(l==r){
        tree[id]=cnt[l];
        return;
    }
    int mid=(l+r)>>1;
    build(l,mid,id<<1);build(mid+1,r,id<<1|1);
    tree[id]=min(tree[id<<1],tree[id<<1|1]);
}
int query(int l,int r,int id,int tl,int tr){
    if(r<tl || tr<l) return inf;
    if(tl<=l && r<=tr) return tree[id];
    int mid=(l+r)>>1;
    return min(query(l,mid,id<<1,tl,tr),query(mid+1,r,id<<1|1,tl,tr))-lazy[id];
}
void update(int l,int r,int id,int tl,int tr){
    if(tr<l || r<tl) return;
    if(tl<=l && r<=tr){
        lazy[id]++;
        tree[id]--;
        return;
    }
    int mid=(l+r)>>1;
    update(l,mid,id<<1,tl,tr);update(mid+1,r,id<<1|1,tl,tr);
    tree[id]=min(tree[id<<1],tree[id<<1|1])-lazy[id];
}

void solve(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i] >> b[i];
        p[i]={b[i],-a[i]};
    }
    for(int i=1;i<=n;i++){
        cin >> c[i] >> d[i];
        p[n+i]={d[i],c[i]};
    }
    sort(p+1,p+2*n+1);
    for(int i=1;i<=2*n;i++) cnt[i]=cnt[i-1]+(p[i].se<0?1:-1);
    build(1,2*n,1);
    int res=0;
    for(int i=1;i<=2*n;i++){
        int x=abs(p[i].se);
        if(p[i].se<0) q[x].push_back(i);
        else if(!q[x].empty()){
            int Min=query(1,2*n,1,q[x].back(),i-1);
            if(Min<=0) continue;
            else{
                res++,update(1,2*n,1,q[x].back(),i-1);
                q[x].pop_back();
            }
        }
    }
    cout << n-res << '\n';
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int test=1;//cin >> test;
    while(test--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16732 KB Output is correct
2 Correct 4 ms 16732 KB Output is correct
3 Correct 4 ms 16732 KB Output is correct
4 Correct 4 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 4 ms 16732 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 16732 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16732 KB Output is correct
2 Correct 4 ms 16732 KB Output is correct
3 Correct 4 ms 16732 KB Output is correct
4 Correct 4 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 4 ms 16732 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 16732 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
13 Correct 3 ms 16884 KB Output is correct
14 Correct 4 ms 16732 KB Output is correct
15 Correct 4 ms 16732 KB Output is correct
16 Correct 4 ms 16732 KB Output is correct
17 Correct 4 ms 16868 KB Output is correct
18 Correct 4 ms 16732 KB Output is correct
19 Correct 4 ms 16732 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 4 ms 16732 KB Output is correct
22 Correct 4 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16732 KB Output is correct
2 Correct 4 ms 16732 KB Output is correct
3 Correct 4 ms 16732 KB Output is correct
4 Correct 4 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 4 ms 16732 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 16732 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
13 Correct 3 ms 16884 KB Output is correct
14 Correct 4 ms 16732 KB Output is correct
15 Correct 4 ms 16732 KB Output is correct
16 Correct 4 ms 16732 KB Output is correct
17 Correct 4 ms 16868 KB Output is correct
18 Correct 4 ms 16732 KB Output is correct
19 Correct 4 ms 16732 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 4 ms 16732 KB Output is correct
22 Correct 4 ms 16732 KB Output is correct
23 Correct 8 ms 21404 KB Output is correct
24 Correct 7 ms 21340 KB Output is correct
25 Correct 7 ms 21340 KB Output is correct
26 Correct 7 ms 19036 KB Output is correct
27 Correct 8 ms 21340 KB Output is correct
28 Correct 8 ms 21084 KB Output is correct
29 Correct 7 ms 21084 KB Output is correct
30 Correct 7 ms 21092 KB Output is correct
31 Correct 7 ms 21092 KB Output is correct
32 Correct 8 ms 21092 KB Output is correct
33 Correct 7 ms 21088 KB Output is correct
34 Correct 8 ms 21084 KB Output is correct
35 Correct 7 ms 21084 KB Output is correct
36 Correct 7 ms 21092 KB Output is correct
37 Correct 7 ms 21084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16732 KB Output is correct
2 Correct 4 ms 16732 KB Output is correct
3 Correct 4 ms 16732 KB Output is correct
4 Correct 4 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 4 ms 16732 KB Output is correct
9 Correct 3 ms 16732 KB Output is correct
10 Correct 4 ms 16732 KB Output is correct
11 Correct 3 ms 16732 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
13 Correct 3 ms 16884 KB Output is correct
14 Correct 4 ms 16732 KB Output is correct
15 Correct 4 ms 16732 KB Output is correct
16 Correct 4 ms 16732 KB Output is correct
17 Correct 4 ms 16868 KB Output is correct
18 Correct 4 ms 16732 KB Output is correct
19 Correct 4 ms 16732 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 4 ms 16732 KB Output is correct
22 Correct 4 ms 16732 KB Output is correct
23 Correct 8 ms 21404 KB Output is correct
24 Correct 7 ms 21340 KB Output is correct
25 Correct 7 ms 21340 KB Output is correct
26 Correct 7 ms 19036 KB Output is correct
27 Correct 8 ms 21340 KB Output is correct
28 Correct 8 ms 21084 KB Output is correct
29 Correct 7 ms 21084 KB Output is correct
30 Correct 7 ms 21092 KB Output is correct
31 Correct 7 ms 21092 KB Output is correct
32 Correct 8 ms 21092 KB Output is correct
33 Correct 7 ms 21088 KB Output is correct
34 Correct 8 ms 21084 KB Output is correct
35 Correct 7 ms 21084 KB Output is correct
36 Correct 7 ms 21092 KB Output is correct
37 Correct 7 ms 21084 KB Output is correct
38 Correct 161 ms 50000 KB Output is correct
39 Correct 152 ms 48996 KB Output is correct
40 Correct 165 ms 48980 KB Output is correct
41 Correct 155 ms 40668 KB Output is correct
42 Correct 191 ms 48964 KB Output is correct
43 Correct 167 ms 44532 KB Output is correct
44 Correct 173 ms 44932 KB Output is correct
45 Correct 163 ms 44884 KB Output is correct
46 Correct 137 ms 44372 KB Output is correct
47 Correct 208 ms 47700 KB Output is correct
48 Correct 161 ms 44112 KB Output is correct
49 Correct 171 ms 43612 KB Output is correct
50 Correct 171 ms 43976 KB Output is correct
51 Correct 129 ms 44648 KB Output is correct
52 Correct 190 ms 45204 KB Output is correct