#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 s < rhs.s;
}
};
ll k;
vector <ll> bit;
void modify(ll x,ll delta){
for (;x<=k;x+= x&-x){
bit[x] = max(bit[x],delta);
}
}
ll query(ll x){
ll ans = 0;
for (;x>0;x-= x&-x){
ans = max(ans,bit[x]);
}
return ans;
}
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 i = 0;
vector <ll> lol;
set <ll> s;
for (int z=0;z<n && i < m;z++,i++){
while (i < m && arr[z].s > frame[i]){
i++;
}
if (i != m){
lol.push_back(arr[z].v);
s.insert(arr[z].v);
}
}
unordered_map <ll,ll> mapp;
ll c = 1;
for (auto it = s.begin();it != s.end();it++){
mapp[*it] = c;
c++;
}
k = lol.size();
vector <ll> dp(k);
bit.resize(k+1);
ll ans = 0;
for (int z=0;z<k;z++){
dp[z] = query(mapp[lol[z]]);
dp[z]++;
modify(mapp[lol[z]],dp[z]);
ans = max(ans,dp[z]);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |