제출 #1344333

#제출 시각아이디문제언어결과실행 시간메모리
1344333minhtienExamination (JOI19_examination)C++20
2 / 100
3093 ms10732 KiB
#include <bits/stdc++.h>
#define iiii pair<int,pair<int,pair<int,int>>>
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
#define fi first
#define se second
using namespace std;
const int N=1e5+6;
int n,q;
vector<int>v;
vector<iiii>v1;
vector<iii>v2;
int k=1;
int a2[N];
int tong1=INT_MAX;
multiset<iii,greater<iii>>v3;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >>n >>q;
    for(int i=1;i<=n;i++){
        int x,y;
        cin >>x >>y;
        v3.insert({x,{y,{x+y}}});
        v2.push_back({x+y,{x,y}});
    }
    for(int i=1;i<=q;i++){
        int x,y,w;
        cin >>x >>y >>w;
        v1.push_back({w,{i,{x,y}}});
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    int k=0;
    for(int i=0;i<v1.size();i++){
        int dem=0;
        while(k<v2.size() && v1[i].fi>v2[k].fi){
            int s=v2[k].fi,s1=v2[k].se.fi,s2=v2[k].se.se;
            v3.erase(v3.find({s1,{s2,s}}));
            k++;
        }
        for(auto x:v3){
            if(x.fi<v1[i].se.se.fi) break;
            if(x.se.fi>=v1[i].se.se.se){
                dem++;
            }
        }
        a2[v1[i].se.fi]=dem;
    }
    for(int i=1;i<=q;i++){
        cout << a2[i] << "\n";
    }
    return 0;
}

/*

10 10
28 2
78 81
39 79
61 31
36 99
90 5
20 55
91 4
48 19
80 7
52 43 78
64 65 171
34 68 124
37 80 161
53 19 123
49 58 109
95 46 30
45 48 60
47 13 54
64 30 144

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...