#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
struct pic{
ll v,s;
bool operator <(const pic& rhs) const{
return v < rhs.v;
}
};
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m;
cin >> n >> m;
vector <pic> arr(n);
for (int z=0;z<n;z++){
cin >> arr[z].s >> arr[z].v;
}
vector <ll> frame(m);
for (int z=0;z<m;z++){
cin >> frame[z];
}
sort(arr.begin(),arr.end());
sort(frame.begin(),frame.end());
ll l = 0;
ll r = 1e9;
ll ans = 0;
while (l <= r){
ll mid = (l+r)/2;
vector <ll> temp;
for (int z=0;z<n;z++){
if (arr[z].s <= mid) temp.push_back(arr[z].s);
}
ll i = 0;
bool ok =false;
for (ll z=0;z<temp.size() && i < m;z++,i++){
while (i < m && temp[z] > frame[i]){
i++;
}
ans = max(ans,z+1);
if (z == temp.size()-1) ok = true;
}
if (ok){
l = mid+1;
} else {
r = mid-1;
}
}
cout << ans << endl;
}
Compilation message
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:49:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (ll z=0;z<temp.size() && i < m;z++,i++){
~^~~~~~~~~~~~
joi2019_ho_t2.cpp:54:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (z == temp.size()-1) ok = true;
~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |