This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("q.gir","r",stdin);
// freopen("q.cik","w",stdout);
int n,m,ans=0,mx=INF;
cin>>n>>m;
map<int,vector<ii>>arr;
map<int,set<int>>Q;
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
arr[x].pb({y,i+1});
Q[y].insert(i+1);
}
for(int i=0;i<m;i++){
int x;
cin>>x;
arr[x].pb({0,0});
}
for(map<int,vector<ii>>::reverse_iterator itr=arr.rbegin();itr!=arr.rend();itr++){
vector<ii>&W=itr->second;
for(int i=0;i<W.size();i++){
if(W[i].second==0&&!Q.empty()){
Q.rbegin()->second.erase(--Q.rbegin()->second.end());
if(Q.rbegin()->second.empty())Q.erase(--Q.end());
ans++;
}
}
for(int i=0;i<W.size();i++){
if(W[i].second){
Q[W[i].first].erase(W[i].second);
if(Q[W[i].first].empty())Q.erase(W[i].first);
}
}
}
cout<<ans;
}
Compilation message (stderr)
joi2019_ho_t2.cpp: In function 'int32_t main()':
joi2019_ho_t2.cpp:34:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<W.size();i++){
~^~~~~~~~~
joi2019_ho_t2.cpp:41:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<W.size();i++){
~^~~~~~~~~
joi2019_ho_t2.cpp:17:21: warning: unused variable 'mx' [-Wunused-variable]
int n,m,ans=0,mx=INF;
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |