#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define P pair<ll, ll>
using namespace std;
const int maxn = 1010;
ll dp[maxn][maxn];
vector<P>v;
ll frames[maxn], n, m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
ll sz, va;
for(int i=1;i<=n;i++) {
cin>>sz>>va;
v.pb(mp(va, sz));
}
v.pb(mp(0, 0));
sort(v.begin(), v.end());
for(int i=1;i<=m;i++) {
cin>>frames[i];
}
sort(frames+1, frames+m+1);
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
if(v[i].second <= frames[j]) {
dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
}
}
}
cout<<dp[n][m]<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
13 ms |
8320 KB |
Output is correct |
21 |
Correct |
12 ms |
8320 KB |
Output is correct |
22 |
Correct |
12 ms |
8320 KB |
Output is correct |
23 |
Correct |
13 ms |
8320 KB |
Output is correct |
24 |
Correct |
13 ms |
8320 KB |
Output is correct |
25 |
Correct |
11 ms |
8320 KB |
Output is correct |
26 |
Correct |
12 ms |
8320 KB |
Output is correct |
27 |
Correct |
11 ms |
8320 KB |
Output is correct |
28 |
Correct |
12 ms |
8320 KB |
Output is correct |
29 |
Correct |
12 ms |
8320 KB |
Output is correct |
30 |
Correct |
12 ms |
8320 KB |
Output is correct |
31 |
Correct |
11 ms |
8320 KB |
Output is correct |
32 |
Correct |
7 ms |
4352 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
10 ms |
6656 KB |
Output is correct |
35 |
Correct |
3 ms |
640 KB |
Output is correct |
36 |
Correct |
12 ms |
8320 KB |
Output is correct |
37 |
Correct |
11 ms |
8320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
13 ms |
8320 KB |
Output is correct |
21 |
Correct |
12 ms |
8320 KB |
Output is correct |
22 |
Correct |
12 ms |
8320 KB |
Output is correct |
23 |
Correct |
13 ms |
8320 KB |
Output is correct |
24 |
Correct |
13 ms |
8320 KB |
Output is correct |
25 |
Correct |
11 ms |
8320 KB |
Output is correct |
26 |
Correct |
12 ms |
8320 KB |
Output is correct |
27 |
Correct |
11 ms |
8320 KB |
Output is correct |
28 |
Correct |
12 ms |
8320 KB |
Output is correct |
29 |
Correct |
12 ms |
8320 KB |
Output is correct |
30 |
Correct |
12 ms |
8320 KB |
Output is correct |
31 |
Correct |
11 ms |
8320 KB |
Output is correct |
32 |
Correct |
7 ms |
4352 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
10 ms |
6656 KB |
Output is correct |
35 |
Correct |
3 ms |
640 KB |
Output is correct |
36 |
Correct |
12 ms |
8320 KB |
Output is correct |
37 |
Correct |
11 ms |
8320 KB |
Output is correct |
38 |
Runtime error |
380 ms |
20048 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
39 |
Halted |
0 ms |
0 KB |
- |