답안 #1072121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072121 2024-08-23T14:38:17 Z vjudge1 Double Attendance (CCO22_day1problem3) C++14
21 / 25
79 ms 63368 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define sz(a) (int)a.size()
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mpp make_pair
const ld PI = 3.14159265359, prec = 1e-9;;
//using u128 = __uint128_t;
//const int x[4] = {1, 0, -1, 0};
//const int y[4] = {0, -1, 0, 1};
const ll mod =1e9 + 7, pr = 31;
const int mxn = 1e6 + 5, mxq = 1e5 + 5, sq = 500, mxv = 5e4 + 1;
//const int base = (1 <<18);
const ll inf = 1e9 + 5, neg = -69420, inf2 = 1e14;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// have fun!
int n1, n2, t;
void comb(pii &a, pii b){
    if(a.fi < b.fi)a = b;
    if(a.fi == b.fi && a.se > b.se)a = b;
}
pii dp[2005][2005][2], one[2005], two[2005];
void solve(){
    cin >> n1 >> n2 >> t;
    for(int i = 1; i <= n1; i++){
        cin >> one[i].fi >> one[i].se;
    }
    sort(one + 1, one + n1 + 1);
    for(int i = 1; i <= n2; i++){
        cin >> two[i].fi >> two[i].se;
    }
    sort(two + 1, two + n2 + 1);
    for(int i = 0; i <= n1; i++){
        for(int j = 0; j <= n2; j++){
            dp[i][j][0] = dp[i][j][1] = mpp(-inf, inf);
        }
    }
    dp[0][0][0] = mpp(0, 0);
    int ans = 0;
    for(int i = 0; i <= n1; i++){
        for(int j = 0; j <= n2; j++){
            for(int k = 0; k < 2; k++){
                if(dp[i][j][k].fi == -inf)continue;
                if(k == 0){
                    if(i < n1){
                        assert(dp[i][j][k].se <= one[i + 1].fi);
                        comb(dp[i + 1][j][0], mpp(dp[i][j][k].fi + 1, one[i + 1].fi));
                    }if(j < n2){
                        comb(dp[i][j + 1][0], dp[i][j][k]);
                        if(dp[i][j][k].se + t < two[j + 1].se){
                            comb(dp[i][j + 1][1], mpp(dp[i][j][k].fi + 1, max(dp[i][j][k].se + t, two[j + 1].fi)));
                        }
                    }
                }else{
                    if(j < n2){
                        assert(dp[i][j][k].se <= two[j + 1].fi);
                        comb(dp[i][j + 1][1], mpp(dp[i][j][k].fi + 1, two[j + 1].fi));
                    }if(i < n1){
                        comb(dp[i + 1][j][1], dp[i][j][k]);
                        if(dp[i][j][k].se + t < one[i + 1].se){
                            comb(dp[i + 1][j][0], mpp(dp[i][j][k].fi + 1, max(dp[i][j][k].se + t, one[i + 1].fi)));
                        }
                    }
                }
                ans = max(ans, dp[i][j][k].fi);
            }
        }
    }
    
    cout << ans;
}
 
 
 
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("THREE.inp", "r", stdin);
    //freopen("THREE.out", "w", stdout);
    int tt; tt = 1;
    while(tt--){
        solve();
 
    }
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 472 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 472 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 464 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 420 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 472 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 472 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 472 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 464 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 420 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 472 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 1116 KB Output is correct
53 Correct 0 ms 860 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 13 ms 20192 KB Output is correct
59 Correct 14 ms 20060 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 860 KB Output is correct
63 Correct 1 ms 860 KB Output is correct
64 Correct 31 ms 41564 KB Output is correct
65 Correct 55 ms 63316 KB Output is correct
66 Correct 38 ms 63324 KB Output is correct
67 Correct 13 ms 19804 KB Output is correct
68 Correct 18 ms 22364 KB Output is correct
69 Correct 29 ms 43868 KB Output is correct
70 Correct 35 ms 44892 KB Output is correct
71 Correct 10 ms 11612 KB Output is correct
72 Correct 1 ms 600 KB Output is correct
73 Correct 1 ms 1112 KB Output is correct
74 Correct 1 ms 604 KB Output is correct
75 Correct 1 ms 860 KB Output is correct
76 Correct 0 ms 604 KB Output is correct
77 Correct 5 ms 9696 KB Output is correct
78 Correct 21 ms 29020 KB Output is correct
79 Correct 34 ms 43092 KB Output is correct
80 Correct 26 ms 39260 KB Output is correct
81 Correct 15 ms 18780 KB Output is correct
82 Correct 3 ms 3676 KB Output is correct
83 Correct 30 ms 43092 KB Output is correct
84 Correct 10 ms 19036 KB Output is correct
85 Correct 29 ms 45804 KB Output is correct
86 Correct 7 ms 11612 KB Output is correct
87 Correct 1 ms 1628 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 0 ms 348 KB Output is correct
92 Correct 0 ms 348 KB Output is correct
93 Correct 0 ms 348 KB Output is correct
94 Correct 0 ms 348 KB Output is correct
95 Correct 0 ms 348 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 2 ms 2908 KB Output is correct
98 Correct 2 ms 2908 KB Output is correct
99 Correct 2 ms 2908 KB Output is correct
100 Correct 2 ms 2908 KB Output is correct
101 Correct 3 ms 3164 KB Output is correct
102 Correct 0 ms 1116 KB Output is correct
103 Correct 0 ms 860 KB Output is correct
104 Correct 0 ms 348 KB Output is correct
105 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 43 ms 63364 KB Output is correct
4 Correct 45 ms 63200 KB Output is correct
5 Correct 49 ms 63316 KB Output is correct
6 Correct 52 ms 63316 KB Output is correct
7 Correct 51 ms 63316 KB Output is correct
8 Correct 49 ms 63324 KB Output is correct
9 Correct 39 ms 63324 KB Output is correct
10 Correct 40 ms 63324 KB Output is correct
11 Correct 3 ms 2908 KB Output is correct
12 Correct 28 ms 32084 KB Output is correct
13 Correct 5 ms 10840 KB Output is correct
14 Correct 55 ms 63316 KB Output is correct
15 Correct 56 ms 63320 KB Output is correct
16 Correct 55 ms 63316 KB Output is correct
17 Correct 35 ms 42332 KB Output is correct
18 Correct 8 ms 11612 KB Output is correct
19 Correct 35 ms 39796 KB Output is correct
20 Correct 54 ms 63360 KB Output is correct
21 Correct 51 ms 63360 KB Output is correct
22 Correct 71 ms 63360 KB Output is correct
23 Correct 29 ms 39260 KB Output is correct
24 Correct 4 ms 4696 KB Output is correct
25 Correct 19 ms 29020 KB Output is correct
26 Correct 27 ms 39260 KB Output is correct
27 Correct 3 ms 4700 KB Output is correct
28 Correct 48 ms 63368 KB Output is correct
29 Correct 19 ms 29788 KB Output is correct
30 Correct 13 ms 16988 KB Output is correct
31 Correct 53 ms 63320 KB Output is correct
32 Correct 36 ms 63284 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 54 ms 63360 KB Output is correct
43 Correct 52 ms 63324 KB Output is correct
44 Correct 53 ms 63320 KB Output is correct
45 Correct 53 ms 63324 KB Output is correct
46 Correct 51 ms 63284 KB Output is correct
47 Correct 3 ms 6624 KB Output is correct
48 Correct 3 ms 7260 KB Output is correct
49 Correct 1 ms 604 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 3 ms 8540 KB Output is correct
52 Correct 4 ms 8792 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 3 ms 8540 KB Output is correct
56 Correct 3 ms 8540 KB Output is correct
57 Correct 1 ms 604 KB Output is correct
58 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 472 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 472 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 464 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 420 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 472 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 1116 KB Output is correct
53 Correct 0 ms 860 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 13 ms 20192 KB Output is correct
59 Correct 14 ms 20060 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 860 KB Output is correct
63 Correct 1 ms 860 KB Output is correct
64 Correct 31 ms 41564 KB Output is correct
65 Correct 55 ms 63316 KB Output is correct
66 Correct 38 ms 63324 KB Output is correct
67 Correct 13 ms 19804 KB Output is correct
68 Correct 18 ms 22364 KB Output is correct
69 Correct 29 ms 43868 KB Output is correct
70 Correct 35 ms 44892 KB Output is correct
71 Correct 10 ms 11612 KB Output is correct
72 Correct 1 ms 600 KB Output is correct
73 Correct 1 ms 1112 KB Output is correct
74 Correct 1 ms 604 KB Output is correct
75 Correct 1 ms 860 KB Output is correct
76 Correct 0 ms 604 KB Output is correct
77 Correct 5 ms 9696 KB Output is correct
78 Correct 21 ms 29020 KB Output is correct
79 Correct 34 ms 43092 KB Output is correct
80 Correct 26 ms 39260 KB Output is correct
81 Correct 15 ms 18780 KB Output is correct
82 Correct 3 ms 3676 KB Output is correct
83 Correct 30 ms 43092 KB Output is correct
84 Correct 10 ms 19036 KB Output is correct
85 Correct 29 ms 45804 KB Output is correct
86 Correct 7 ms 11612 KB Output is correct
87 Correct 1 ms 1628 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 0 ms 348 KB Output is correct
92 Correct 0 ms 348 KB Output is correct
93 Correct 0 ms 348 KB Output is correct
94 Correct 0 ms 348 KB Output is correct
95 Correct 0 ms 348 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 2 ms 2908 KB Output is correct
98 Correct 2 ms 2908 KB Output is correct
99 Correct 2 ms 2908 KB Output is correct
100 Correct 2 ms 2908 KB Output is correct
101 Correct 3 ms 3164 KB Output is correct
102 Correct 0 ms 1116 KB Output is correct
103 Correct 0 ms 860 KB Output is correct
104 Correct 0 ms 348 KB Output is correct
105 Correct 1 ms 348 KB Output is correct
106 Correct 0 ms 348 KB Output is correct
107 Correct 1 ms 348 KB Output is correct
108 Correct 43 ms 63364 KB Output is correct
109 Correct 45 ms 63200 KB Output is correct
110 Correct 49 ms 63316 KB Output is correct
111 Correct 52 ms 63316 KB Output is correct
112 Correct 51 ms 63316 KB Output is correct
113 Correct 49 ms 63324 KB Output is correct
114 Correct 39 ms 63324 KB Output is correct
115 Correct 40 ms 63324 KB Output is correct
116 Correct 3 ms 2908 KB Output is correct
117 Correct 28 ms 32084 KB Output is correct
118 Correct 5 ms 10840 KB Output is correct
119 Correct 55 ms 63316 KB Output is correct
120 Correct 56 ms 63320 KB Output is correct
121 Correct 55 ms 63316 KB Output is correct
122 Correct 35 ms 42332 KB Output is correct
123 Correct 8 ms 11612 KB Output is correct
124 Correct 35 ms 39796 KB Output is correct
125 Correct 54 ms 63360 KB Output is correct
126 Correct 51 ms 63360 KB Output is correct
127 Correct 71 ms 63360 KB Output is correct
128 Correct 29 ms 39260 KB Output is correct
129 Correct 4 ms 4696 KB Output is correct
130 Correct 19 ms 29020 KB Output is correct
131 Correct 27 ms 39260 KB Output is correct
132 Correct 3 ms 4700 KB Output is correct
133 Correct 48 ms 63368 KB Output is correct
134 Correct 19 ms 29788 KB Output is correct
135 Correct 13 ms 16988 KB Output is correct
136 Correct 53 ms 63320 KB Output is correct
137 Correct 36 ms 63284 KB Output is correct
138 Correct 1 ms 348 KB Output is correct
139 Correct 0 ms 348 KB Output is correct
140 Correct 0 ms 348 KB Output is correct
141 Correct 0 ms 348 KB Output is correct
142 Correct 0 ms 348 KB Output is correct
143 Correct 0 ms 348 KB Output is correct
144 Correct 0 ms 348 KB Output is correct
145 Correct 0 ms 348 KB Output is correct
146 Correct 0 ms 348 KB Output is correct
147 Correct 54 ms 63360 KB Output is correct
148 Correct 52 ms 63324 KB Output is correct
149 Correct 53 ms 63320 KB Output is correct
150 Correct 53 ms 63324 KB Output is correct
151 Correct 51 ms 63284 KB Output is correct
152 Correct 3 ms 6624 KB Output is correct
153 Correct 3 ms 7260 KB Output is correct
154 Correct 1 ms 604 KB Output is correct
155 Correct 1 ms 344 KB Output is correct
156 Correct 3 ms 8540 KB Output is correct
157 Correct 4 ms 8792 KB Output is correct
158 Correct 1 ms 348 KB Output is correct
159 Correct 1 ms 348 KB Output is correct
160 Correct 3 ms 8540 KB Output is correct
161 Correct 3 ms 8540 KB Output is correct
162 Correct 1 ms 604 KB Output is correct
163 Correct 1 ms 604 KB Output is correct
164 Correct 0 ms 348 KB Output is correct
165 Runtime error 79 ms 14052 KB Execution killed with signal 6
166 Halted 0 ms 0 KB -