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 <algorithm>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#define F first
#define S second
#define PB push_back
using namespace std;
const long long MOD=1e9+7, INF=1e18;
const int INFI=1e9;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<pair<int, ii>> viii;
typedef vector<vii> vvii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m; cin>>n>>m;
vii p(n+1), dp(m+1, {0, 0});
vi f(m+1);
for(int i=1;i<=n;i++) cin>>p[i].S>>p[i].F;
for(int i=1;i<=m;i++) cin>>f[i];
sort(p.begin()+1, p.end());
sort(f.begin()+1, f.end());
for(int i=1;i<=n;i++){
int cntmx=0, ind=1, sz=p[i].S, val=p[i].F;
for(;ind<=m && f[ind]<sz;ind++){}
for(int j=1;j<ind;j++)
if(dp[j].F>cntmx) cntmx=dp[j].F;
for(;ind<=m;ind++){
int aux=dp[ind].F;
if(cntmx+1>aux) dp[ind]={cntmx+1, val};
if(aux>cntmx) cntmx=aux;
}
}
cout<<dp[m].F<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |