#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
template<class T>
bool operator()(T const &a, T const &b) const { return a > b; }
};
ll n,m;
vedos hedi;
ve frames;
map<pair<ll,pair<ll,ll>>,ll>dp;
ll solve(ll pic,ll frame,ll last)
{
if(pic==n || frame==m)return 0;
//if(dp.find({pic,{frame,last}})!=dp.end())return dp[{pic,{frame,last}}];
ll ans=0;
if((hedi[pic].second>=hedi[last].second||last==-1) && hedi[pic].first<=frames[frame])
{
ans=max(ans,1+solve(pic+1,frame+1,pic));
}
ans=max(ans,solve(pic+1,frame,last));
ans=max(ans,solve(pic,frame+1,last));
return dp[{pic,{frame,last}}]=ans;
}
int main()
{
//flash;
cin>>n>>m;
for (ll i = 0; i < n; ++i)
{
ll x,y;
cin>>x>>y;
hedi.pb({x,y});
}
for (ll i = 0; i < m; ++i)
{
ll yo;
cin>>yo;
frames.pb(yo);
}
sort(hedi.begin(),hedi.end());
sort(frames.begin(),frames.end());
cout<<solve(0,0,-1);
return 0;
}
//code the AC sol !
// BS/queue/map
Compilation message
joi2019_ho_t2.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("O3")
joi2019_ho_t2.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization ("unroll-loops")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
62 ms |
376 KB |
Output is correct |
3 |
Correct |
93 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
62 ms |
376 KB |
Output is correct |
3 |
Correct |
93 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
62 ms |
376 KB |
Output is correct |
3 |
Correct |
93 ms |
504 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |