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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
typedef vector<ll> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
ll dp[2][1001],cc;
vi c;
vii paint;
ii s;
int main(){
int n,m;cin>>n>>m;
for(int i = 0; i < n; i++){
cin >> s.se >> s.fi;
paint.pb(s);
}
sort(paint.begin(),paint.end());
for(int i = 0; i < m; i++){
cin >> cc;
c.pb(cc);
}
c.pb(0);
sort(c.begin(),c.end());
ll ans=0;
for(int i = 0; i < n; i++){
ll cmax=0;
for(int j = 1; j <= m; j++){
cmax=max(dp[(i+2)%2][j-1],cmax);
dp[i%2][j]=dp[(i+1)%2][j];
if(paint[i%2].se<=c[j]) dp[i%2][j]=max(dp[i%2][j],cmax+1);
ans=max(ans,dp[i%2][j]);
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |