제출 #1358898

#제출 시각아이디문제언어결과실행 시간메모리
1358898hasanMatryoshka (JOI16_matryoshka)C++20
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define int int_fast64_t
#define ul uint_fast32_t
#define ll int_fast64_t
#define dll long double
#define ull uint_fast64_t
#define spektar this_thread::sleep_for(chrono::milliseconds(50))

ll log2floor(ull n){ return 63-__builtin_clzll(n); }

bool cmp(array<int,2> a,array<int,2> b){
    if(a[0]!=b[0]) return a<b;
    else return a[1]>b[1];
}

void solve(){
    int n,m;
    cin >> n >> m;
    vector<array<int,2>> k(n);
    for(auto& [a,b]:k) cin >> a >> b;
    sort(k.begin(),k.end(),cmp);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        deque<array<int,2>> V;
        multiset<array<int,2>> kk;
        for(int j=0; j<n; j++){
            if(k[j][0]>=a && k[j][1]<=b){
                V.push_back(k[j]);
                kk.insert({k[j][1],(int)V.size()-1});
            }
        }
        vector<int> used(V.size());
        int s=0;
        for(int j=0; j<V.size(); j++){
            if(!used[j]) kk.erase(kk.find({V[j][1],j}));
            if(kk.upper_bound({V[j][1],j})==kk.end()) s++;
            else{
                used[(*kk.upper_bound({V[j][1],j}))[1]]=1;
                kk.erase(kk.upper_bound({V[j][1],j}));
            }
        }
        cout << s << endl;
    }
}

signed main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…