Submission #1297869

#TimeUsernameProblemLanguageResultExecution timeMemory
1297869kiteyuExhibition (JOI19_ho_t2)C++20
100 / 100
36 ms1608 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; using ll = long long; const int N = 1e5; int n,m; pair<int,int>a[N+5]; int b[N+5]; bool cmp(pair<int,int> x,pair<int,int> y){ if(x.se!=y.se) return x.se < y.se; return x.fi < y.fi; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i = 1 ; i <= n ; ++i) cin >> a[i].fi >> a[i].se; for(int i = 1 ; i <= m ; ++i) cin >> b[i]; sort(a+1,a+1+n,cmp); sort(b+1,b+1+m); int j = n; int ans = 0; // for(int i = 1 ; i <= n ; ++i) cout << a[i].fi << ' ' << a[i].se << '\n'; for(int i = m ; i >= 1 ; --i){ while(a[j].fi>b[i]) j--; if(j > 0 && a[j].fi <= b[i]){ ans++; j--; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...