답안 #721009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721009 2023-04-10T03:45:18 Z Pring Exhibition (JOI19_ho_t2) C++14
50 / 100
1000 ms 4836 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int, int> pii;
 
const int MXN = 100005;
int n, m, fr[MXN], dp[MXN], lastC, ans, pre[MXN];
 
struct P {
    int sz, val;
    P() {
        sz = 0;
        val = 0;
    }
    P(int _sz, int _val) {
        sz = _sz;
        val = _val;
    }
} pic[MXN];
 
void getDP(int id) {
    // cout << "id: " << id << endl;
    lastC = 0;
    while (pic[id].sz > fr[lastC]) lastC++;
    // cout << "lastC: " << lastC << endl;
    // vector<int> avail;
    // for (int i = 0; i < id; i++) if (pic[i].val <= pic[id].val) avail.push_back(i);
    // cout << "avail: ";
    // for (auto &i : avail) cout << i << ' ';
    // cout << endl;
    for (int i = lastC; i < m; i++) {
        // dp[id][i] = 1;
        dp[i] = max(1LL, pre[i - 1] + 1);
        // pre[i] = max(pre[i], dp[id][i]);
        // for (auto &j : avail) {
        //     dp[id][i] = max(dp[id][i], dp[j][i - 1] + 1);
        // }
    }
    for (int i = 0; i < m; i++) pre[i] = max(pre[i], dp[i]);
    ans = max(ans, dp[m - 1]);
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> pic[i].sz >> pic[i].val;
    for (int i = 0; i < m; i++) cin >> fr[i];
    sort(pic, pic + n, [](P &a, P &b) {
        return (a.val == b.val ? a.sz < b.sz : a.val < b.val);
    });
    sort(fr, fr + m);
    fr[m] = LLONG_MAX;
    for (int i = 0; i < n; i++) {
        getDP(i);
    }
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < m; j++) {
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    cout << ans << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 3 ms 1876 KB Output is correct
21 Correct 3 ms 1876 KB Output is correct
22 Correct 3 ms 1876 KB Output is correct
23 Correct 3 ms 1876 KB Output is correct
24 Correct 3 ms 1876 KB Output is correct
25 Correct 3 ms 1876 KB Output is correct
26 Correct 4 ms 1876 KB Output is correct
27 Correct 3 ms 1876 KB Output is correct
28 Correct 2 ms 1876 KB Output is correct
29 Correct 3 ms 1876 KB Output is correct
30 Correct 3 ms 1876 KB Output is correct
31 Correct 3 ms 1876 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 1 ms 1876 KB Output is correct
34 Correct 2 ms 1876 KB Output is correct
35 Correct 1 ms 1876 KB Output is correct
36 Correct 3 ms 1876 KB Output is correct
37 Correct 3 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1876 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1876 KB Output is correct
8 Correct 1 ms 1876 KB Output is correct
9 Correct 1 ms 1876 KB Output is correct
10 Correct 1 ms 1876 KB Output is correct
11 Correct 1 ms 1876 KB Output is correct
12 Correct 1 ms 1876 KB Output is correct
13 Correct 1 ms 1876 KB Output is correct
14 Correct 1 ms 1876 KB Output is correct
15 Correct 1 ms 1876 KB Output is correct
16 Correct 1 ms 1876 KB Output is correct
17 Correct 1 ms 1876 KB Output is correct
18 Correct 1 ms 1876 KB Output is correct
19 Correct 1 ms 1876 KB Output is correct
20 Correct 3 ms 1876 KB Output is correct
21 Correct 3 ms 1876 KB Output is correct
22 Correct 3 ms 1876 KB Output is correct
23 Correct 3 ms 1876 KB Output is correct
24 Correct 3 ms 1876 KB Output is correct
25 Correct 3 ms 1876 KB Output is correct
26 Correct 4 ms 1876 KB Output is correct
27 Correct 3 ms 1876 KB Output is correct
28 Correct 2 ms 1876 KB Output is correct
29 Correct 3 ms 1876 KB Output is correct
30 Correct 3 ms 1876 KB Output is correct
31 Correct 3 ms 1876 KB Output is correct
32 Correct 1 ms 1876 KB Output is correct
33 Correct 1 ms 1876 KB Output is correct
34 Correct 2 ms 1876 KB Output is correct
35 Correct 1 ms 1876 KB Output is correct
36 Correct 3 ms 1876 KB Output is correct
37 Correct 3 ms 1876 KB Output is correct
38 Execution timed out 1076 ms 4836 KB Time limit exceeded
39 Halted 0 ms 0 KB -