/*
"TLE is like the wind, always by my side"
- Yasuo - 2022 -
*/
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast")
#define int long long
using namespace std;
struct painting
{
int s;
int v;
};
painting a[100001];
int sz[100001];
int n,m,i,j,r,pas;
bool cmp(painting aa, painting bb)
{
return aa.v<bb.v;
}
bool good(int len)
{
int k;
bool done;
done=false;
k=m-len+1;
for (i=1;i<=n;i++)
{
if (a[i].s<=sz[k])
k++;
if (k==m+1)
{
done=true;
break;
}
}
return done;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (i=1;i<=n;i++)
{
cin >> a[i].s >> a[i].v;
}
for (i=1;i<=m;i++)
{
cin >> sz[i];
}
sort(sz+1,sz+1+m);
sort(a+1,a+1+n,cmp);
r=0;
pas=(1<<18);
while (pas)
{
if (r+pas<=n && good(r+pas))
r+=pas;
pas=pas/2;
}
cout << r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |