#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
// jangan kebiasa kalah
// kalo OI, sampah aja dulu, tapi jangan menutup kemungkinan buat AC
long long n,m,b[100069];
pll arr[100069];
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long i,j;
cin>>n>>m;
for(i=1;i<=n;i++)
{
cin>>arr[i].se>>arr[i].fi;
}
j = 1;
bool pernah = 0;
for(i=1;i<=m;i++)
{
cin>>b[i];
}
sort(arr+1,arr+n+1);
sort(b+1,b+m+1);
// i < j -> b[i] <= b[j] and arr[i].fi <= arr[j].fi
// fi = val, se = size
for(i=1;i<=n and j<=m;i++)
{
if(arr[i].se <= b[j])
{
j++;
pernah = 1;
}
}
j *= pernah;
cout<<j<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |