Submission #669728

#TimeUsernameProblemLanguageResultExecution timeMemory
669728dsyzArt Exhibition (JOI18_art)C++17
0 / 100
99 ms262144 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MAXN (1000005) int main(){ ios_base::sync_with_stdio(false);cin.tie(0); ll N,M; cin>>N>>M; pair<ll,ll> arr[N]; //s, v for(ll i = 0;i < N;i++){ cin>>arr[i].first>>arr[i].second; } ll C[M]; for(ll i = 0;i < M;i++){ cin>>C[i]; } sort(arr,arr + N); sort(C,C + M); priority_queue<pair<ll,ll> > pq; ll ptr = -1; while(ptr < N - 1 && arr[ptr + 1].first <= C[M - 1]){ ptr++; pq.push(make_pair(arr[ptr].second,arr[ptr].first)); } ll ans = 0; ll prev = 1e18; for(ll i = M - 1;i >= 0;i--){ while(!pq.empty() && (pq.top().first > prev || pq.top().second > C[i])){ pq.pop(); } if(!pq.empty()){ ans++; pq.pop(); } } cout<<ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...