제출 #1123395

#제출 시각아이디문제언어결과실행 시간메모리
1123395LucaIlieExhibition (JOI19_ho_t2)C++20
100 / 100
53 ms2452 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...