#include <bits/stdc++.h>
using namespace std;
struct painting {
int size, value, frames;
};
struct AIB {
int n;
vector<int> aib;
void init( int _n ) {
n = _n;
aib.clear();
aib.resize( n + 1 );
}
void update( int i, int x ) {
while ( i <= n ) {
aib[i] = max( aib[i], x );
i += (i & -i);
}
}
int query( int i ) {
int s = 0;
while ( i > 0 ) {
s = max( s, aib[i] );
i -= (i & -i);
}
return s;
}
};
const int MAX_N = 1e5;
const int MAX_M = 1e5;
painting paintings[MAX_N + 1];
int dp[MAX_N + 1], frames[MAX_M + 1];
int main() {
ios_base::sync_with_stdio( false );
cin.tie( nullptr );
int n, m;
cin >> n >> m;
for ( int i = 1; i <= n; i++ )
cin >> paintings[i].size >> paintings[i].value;
for ( int i = 1; i <= m; i++ )
cin >> frames[i];
sort( paintings + 1, paintings + 1 + n, []( painting a, painting b ) {
if ( a.size == b.size )
return a.value > b.value;
return a.size > b.size;
} );
sort( frames + 1, frames + 1 + m );
int j = m;
for ( int i = 1; i <= n; i++ ) {
while ( j >= 1 && frames[j] >= paintings[i].size )
j--;
paintings[i].frames = m - j;
}
sort( paintings + 1, paintings + 1 + n, []( painting a, painting b ) {
if ( a.value == b.value )
return a.frames < b.frames;
return a.value > b.value;
} );
int maxDp = 0;
for ( int i = 1; i <= n; i++ ) {
dp[i] = min( paintings[i].frames, maxDp + 1 );
maxDp = max( maxDp, dp[i] );
}
cout << maxDp << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |