답안 #971480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971480 2024-04-28T15:59:06 Z KiaRez Double Attendance (CCO22_day1problem3) C++17
15 / 25
360 ms 28256 KB
/*
    IN THE NAME OF GOD
*/
#include <bits/stdc++.h>

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;

#define F                                      first
#define S                                      second
#define Mp                                     make_pair
#define pb                                     push_back
#define pf                                     push_front
#define size(x)                                ((ll)x.size())
#define all(x)                                 (x).begin(),(x).end()
#define kill(x)		                           cout << x << '\n', exit(0);
#define fuck(x)                                cout << "(" << #x << " , " << x << ")" << endl
#define endl                                   '\n'

const int N = 3e5+23, lg = 18;
ll Mod = 1e9+7; //998244353;

inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;}
inline ll poww(ll a, ll b, ll mod=Mod) {
    ll ans = 1;
    a=MOD(a, mod);
    while (b) {
        if (b & 1) ans = MOD(ans*a, mod);
        b >>= 1;
        a = MOD(a*a, mod);
    }
    return ans;
}

int n, m, k, dp[2][2005][2005];
set<pii> st[2];
int main () {
	ios_base::sync_with_stdio(false), cin.tie(0);

	cin>>n>>m>>k;
    if(n>2000 || m>2000) kill(0);
    for(int x,y,i=1; i<=n; i++) {
        cin>>x>>y;
        st[0].insert({y, x});
    }
    for(int x,y,i=1; i<=m; i++) {
        cin>>x>>y;
        st[1].insert({y, x});
    }
    for(int i=2000; i>=0; i--) {
        for(int j=2000; j>=i; j--) {
            auto t1 = (st[0].lower_bound({j+1, 0}));
            int x = 0, y = 0;
            if(t1!=st[0].end()&&(*t1).F==j+1&&(*t1).S>=i) x++;
            if(t1!=st[0].end()&&(*t1).S>=i&&(*t1).S<=j) y++;

            if(j+k > 2000) {
                dp[0][i][j] += (dp[0][i][j+1]+x);
            } else {
                auto t2 = st[1].lower_bound({j+k+1, 0});
                if(t2!=st[1].end()&&(*t2).S>=i&&(*t2).S<=j) {
dp[0][i][j] = max((dp[0][i][j+1]+x), y+dp[1][j+1][j+k]+1);
                } else {
dp[0][i][j] = max((dp[0][i][j+1]+x), y+dp[1][j+1][j+k]);
                }
            }

            auto t2 = (st[1].lower_bound({j+1, 0}));
            x = 0, y = 0;
            if(t2!=st[1].end()&&(*t2).F==j+1&&(*t2).S>=i) x++;
            if(t2!=st[1].end()&&(*t2).S>=i&&(*t2).S<=j) y++;

            if(j+k > 2000) {
                dp[1][i][j] += (dp[1][i][j+1]+x);
            } else {
                auto t3 = st[0].lower_bound({j+k+1, 0});
                if(t3!=st[0].end()&&(*t3).S>=i&&(*t3).S<=j) {
dp[1][i][j] = max((dp[1][i][j+1]+x), y+dp[0][j+1][j+k]+1);
                } else {
dp[1][i][j] = max((dp[1][i][j+1]+x), y+dp[0][j+1][j+k]);
                }
            }
        }
    }

    cout<<dp[0][0][0]<<endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 27988 KB Output is correct
2 Correct 39 ms 27836 KB Output is correct
3 Correct 47 ms 28088 KB Output is correct
4 Correct 37 ms 27988 KB Output is correct
5 Correct 42 ms 27988 KB Output is correct
6 Correct 59 ms 28032 KB Output is correct
7 Correct 62 ms 27984 KB Output is correct
8 Correct 53 ms 28008 KB Output is correct
9 Correct 54 ms 27984 KB Output is correct
10 Correct 62 ms 27984 KB Output is correct
11 Correct 28 ms 27992 KB Output is correct
12 Correct 64 ms 27984 KB Output is correct
13 Correct 66 ms 27984 KB Output is correct
14 Correct 62 ms 27920 KB Output is correct
15 Correct 65 ms 27984 KB Output is correct
16 Correct 62 ms 27988 KB Output is correct
17 Correct 65 ms 27984 KB Output is correct
18 Correct 36 ms 27988 KB Output is correct
19 Correct 30 ms 27908 KB Output is correct
20 Correct 30 ms 27984 KB Output is correct
21 Correct 29 ms 27996 KB Output is correct
22 Correct 27 ms 27996 KB Output is correct
23 Correct 31 ms 28116 KB Output is correct
24 Correct 36 ms 27988 KB Output is correct
25 Correct 39 ms 27988 KB Output is correct
26 Correct 49 ms 28084 KB Output is correct
27 Correct 34 ms 27992 KB Output is correct
28 Correct 35 ms 27984 KB Output is correct
29 Correct 36 ms 27984 KB Output is correct
30 Correct 43 ms 27964 KB Output is correct
31 Correct 35 ms 27988 KB Output is correct
32 Correct 51 ms 27992 KB Output is correct
33 Correct 52 ms 28020 KB Output is correct
34 Correct 47 ms 27984 KB Output is correct
35 Correct 47 ms 27988 KB Output is correct
36 Correct 50 ms 27984 KB Output is correct
37 Correct 48 ms 27952 KB Output is correct
38 Correct 54 ms 28164 KB Output is correct
39 Correct 48 ms 27984 KB Output is correct
40 Correct 64 ms 28028 KB Output is correct
41 Correct 59 ms 27988 KB Output is correct
42 Correct 53 ms 27980 KB Output is correct
43 Correct 61 ms 27984 KB Output is correct
44 Correct 49 ms 27984 KB Output is correct
45 Correct 59 ms 28000 KB Output is correct
46 Correct 47 ms 27984 KB Output is correct
47 Correct 52 ms 27984 KB Output is correct
48 Correct 49 ms 27988 KB Output is correct
49 Correct 58 ms 28088 KB Output is correct
50 Correct 39 ms 27988 KB Output is correct
51 Correct 40 ms 27988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 27988 KB Output is correct
2 Correct 39 ms 27836 KB Output is correct
3 Correct 47 ms 28088 KB Output is correct
4 Correct 37 ms 27988 KB Output is correct
5 Correct 42 ms 27988 KB Output is correct
6 Correct 59 ms 28032 KB Output is correct
7 Correct 62 ms 27984 KB Output is correct
8 Correct 53 ms 28008 KB Output is correct
9 Correct 54 ms 27984 KB Output is correct
10 Correct 62 ms 27984 KB Output is correct
11 Correct 28 ms 27992 KB Output is correct
12 Correct 64 ms 27984 KB Output is correct
13 Correct 66 ms 27984 KB Output is correct
14 Correct 62 ms 27920 KB Output is correct
15 Correct 65 ms 27984 KB Output is correct
16 Correct 62 ms 27988 KB Output is correct
17 Correct 65 ms 27984 KB Output is correct
18 Correct 36 ms 27988 KB Output is correct
19 Correct 30 ms 27908 KB Output is correct
20 Correct 30 ms 27984 KB Output is correct
21 Correct 29 ms 27996 KB Output is correct
22 Correct 27 ms 27996 KB Output is correct
23 Correct 31 ms 28116 KB Output is correct
24 Correct 36 ms 27988 KB Output is correct
25 Correct 39 ms 27988 KB Output is correct
26 Correct 49 ms 28084 KB Output is correct
27 Correct 34 ms 27992 KB Output is correct
28 Correct 35 ms 27984 KB Output is correct
29 Correct 36 ms 27984 KB Output is correct
30 Correct 43 ms 27964 KB Output is correct
31 Correct 35 ms 27988 KB Output is correct
32 Correct 51 ms 27992 KB Output is correct
33 Correct 52 ms 28020 KB Output is correct
34 Correct 47 ms 27984 KB Output is correct
35 Correct 47 ms 27988 KB Output is correct
36 Correct 50 ms 27984 KB Output is correct
37 Correct 48 ms 27952 KB Output is correct
38 Correct 54 ms 28164 KB Output is correct
39 Correct 48 ms 27984 KB Output is correct
40 Correct 64 ms 28028 KB Output is correct
41 Correct 59 ms 27988 KB Output is correct
42 Correct 53 ms 27980 KB Output is correct
43 Correct 61 ms 27984 KB Output is correct
44 Correct 49 ms 27984 KB Output is correct
45 Correct 59 ms 28000 KB Output is correct
46 Correct 47 ms 27984 KB Output is correct
47 Correct 52 ms 27984 KB Output is correct
48 Correct 49 ms 27988 KB Output is correct
49 Correct 58 ms 28088 KB Output is correct
50 Correct 39 ms 27988 KB Output is correct
51 Correct 40 ms 27988 KB Output is correct
52 Correct 88 ms 27988 KB Output is correct
53 Correct 76 ms 27844 KB Output is correct
54 Correct 79 ms 27984 KB Output is correct
55 Correct 95 ms 27984 KB Output is correct
56 Correct 40 ms 28016 KB Output is correct
57 Correct 188 ms 28032 KB Output is correct
58 Correct 330 ms 28076 KB Output is correct
59 Correct 324 ms 27984 KB Output is correct
60 Correct 56 ms 27988 KB Output is correct
61 Correct 54 ms 27988 KB Output is correct
62 Correct 98 ms 27844 KB Output is correct
63 Correct 103 ms 27984 KB Output is correct
64 Correct 354 ms 28124 KB Output is correct
65 Correct 191 ms 28196 KB Output is correct
66 Correct 188 ms 28196 KB Output is correct
67 Correct 289 ms 28136 KB Output is correct
68 Correct 318 ms 27984 KB Output is correct
69 Correct 348 ms 28076 KB Output is correct
70 Correct 360 ms 28244 KB Output is correct
71 Correct 242 ms 28240 KB Output is correct
72 Correct 88 ms 27984 KB Output is correct
73 Correct 102 ms 27988 KB Output is correct
74 Correct 101 ms 27984 KB Output is correct
75 Correct 109 ms 28012 KB Output is correct
76 Correct 94 ms 28016 KB Output is correct
77 Correct 236 ms 27988 KB Output is correct
78 Correct 318 ms 28024 KB Output is correct
79 Correct 345 ms 28056 KB Output is correct
80 Correct 333 ms 28256 KB Output is correct
81 Correct 290 ms 28208 KB Output is correct
82 Correct 146 ms 27988 KB Output is correct
83 Correct 219 ms 28240 KB Output is correct
84 Correct 151 ms 27992 KB Output is correct
85 Correct 231 ms 28244 KB Output is correct
86 Correct 153 ms 28156 KB Output is correct
87 Correct 58 ms 27936 KB Output is correct
88 Correct 19 ms 27996 KB Output is correct
89 Correct 29 ms 27960 KB Output is correct
90 Correct 19 ms 27996 KB Output is correct
91 Correct 20 ms 27984 KB Output is correct
92 Correct 25 ms 28136 KB Output is correct
93 Correct 26 ms 27996 KB Output is correct
94 Correct 28 ms 27992 KB Output is correct
95 Correct 22 ms 28240 KB Output is correct
96 Correct 21 ms 27992 KB Output is correct
97 Correct 186 ms 27876 KB Output is correct
98 Correct 181 ms 28236 KB Output is correct
99 Correct 187 ms 28000 KB Output is correct
100 Correct 178 ms 27948 KB Output is correct
101 Correct 179 ms 28008 KB Output is correct
102 Correct 85 ms 27856 KB Output is correct
103 Correct 70 ms 28040 KB Output is correct
104 Correct 85 ms 27984 KB Output is correct
105 Correct 79 ms 27904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 27988 KB Output is correct
2 Incorrect 186 ms 28116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 27988 KB Output is correct
2 Correct 39 ms 27836 KB Output is correct
3 Correct 47 ms 28088 KB Output is correct
4 Correct 37 ms 27988 KB Output is correct
5 Correct 42 ms 27988 KB Output is correct
6 Correct 59 ms 28032 KB Output is correct
7 Correct 62 ms 27984 KB Output is correct
8 Correct 53 ms 28008 KB Output is correct
9 Correct 54 ms 27984 KB Output is correct
10 Correct 62 ms 27984 KB Output is correct
11 Correct 28 ms 27992 KB Output is correct
12 Correct 64 ms 27984 KB Output is correct
13 Correct 66 ms 27984 KB Output is correct
14 Correct 62 ms 27920 KB Output is correct
15 Correct 65 ms 27984 KB Output is correct
16 Correct 62 ms 27988 KB Output is correct
17 Correct 65 ms 27984 KB Output is correct
18 Correct 36 ms 27988 KB Output is correct
19 Correct 30 ms 27908 KB Output is correct
20 Correct 30 ms 27984 KB Output is correct
21 Correct 29 ms 27996 KB Output is correct
22 Correct 27 ms 27996 KB Output is correct
23 Correct 31 ms 28116 KB Output is correct
24 Correct 36 ms 27988 KB Output is correct
25 Correct 39 ms 27988 KB Output is correct
26 Correct 49 ms 28084 KB Output is correct
27 Correct 34 ms 27992 KB Output is correct
28 Correct 35 ms 27984 KB Output is correct
29 Correct 36 ms 27984 KB Output is correct
30 Correct 43 ms 27964 KB Output is correct
31 Correct 35 ms 27988 KB Output is correct
32 Correct 51 ms 27992 KB Output is correct
33 Correct 52 ms 28020 KB Output is correct
34 Correct 47 ms 27984 KB Output is correct
35 Correct 47 ms 27988 KB Output is correct
36 Correct 50 ms 27984 KB Output is correct
37 Correct 48 ms 27952 KB Output is correct
38 Correct 54 ms 28164 KB Output is correct
39 Correct 48 ms 27984 KB Output is correct
40 Correct 64 ms 28028 KB Output is correct
41 Correct 59 ms 27988 KB Output is correct
42 Correct 53 ms 27980 KB Output is correct
43 Correct 61 ms 27984 KB Output is correct
44 Correct 49 ms 27984 KB Output is correct
45 Correct 59 ms 28000 KB Output is correct
46 Correct 47 ms 27984 KB Output is correct
47 Correct 52 ms 27984 KB Output is correct
48 Correct 49 ms 27988 KB Output is correct
49 Correct 58 ms 28088 KB Output is correct
50 Correct 39 ms 27988 KB Output is correct
51 Correct 40 ms 27988 KB Output is correct
52 Correct 88 ms 27988 KB Output is correct
53 Correct 76 ms 27844 KB Output is correct
54 Correct 79 ms 27984 KB Output is correct
55 Correct 95 ms 27984 KB Output is correct
56 Correct 40 ms 28016 KB Output is correct
57 Correct 188 ms 28032 KB Output is correct
58 Correct 330 ms 28076 KB Output is correct
59 Correct 324 ms 27984 KB Output is correct
60 Correct 56 ms 27988 KB Output is correct
61 Correct 54 ms 27988 KB Output is correct
62 Correct 98 ms 27844 KB Output is correct
63 Correct 103 ms 27984 KB Output is correct
64 Correct 354 ms 28124 KB Output is correct
65 Correct 191 ms 28196 KB Output is correct
66 Correct 188 ms 28196 KB Output is correct
67 Correct 289 ms 28136 KB Output is correct
68 Correct 318 ms 27984 KB Output is correct
69 Correct 348 ms 28076 KB Output is correct
70 Correct 360 ms 28244 KB Output is correct
71 Correct 242 ms 28240 KB Output is correct
72 Correct 88 ms 27984 KB Output is correct
73 Correct 102 ms 27988 KB Output is correct
74 Correct 101 ms 27984 KB Output is correct
75 Correct 109 ms 28012 KB Output is correct
76 Correct 94 ms 28016 KB Output is correct
77 Correct 236 ms 27988 KB Output is correct
78 Correct 318 ms 28024 KB Output is correct
79 Correct 345 ms 28056 KB Output is correct
80 Correct 333 ms 28256 KB Output is correct
81 Correct 290 ms 28208 KB Output is correct
82 Correct 146 ms 27988 KB Output is correct
83 Correct 219 ms 28240 KB Output is correct
84 Correct 151 ms 27992 KB Output is correct
85 Correct 231 ms 28244 KB Output is correct
86 Correct 153 ms 28156 KB Output is correct
87 Correct 58 ms 27936 KB Output is correct
88 Correct 19 ms 27996 KB Output is correct
89 Correct 29 ms 27960 KB Output is correct
90 Correct 19 ms 27996 KB Output is correct
91 Correct 20 ms 27984 KB Output is correct
92 Correct 25 ms 28136 KB Output is correct
93 Correct 26 ms 27996 KB Output is correct
94 Correct 28 ms 27992 KB Output is correct
95 Correct 22 ms 28240 KB Output is correct
96 Correct 21 ms 27992 KB Output is correct
97 Correct 186 ms 27876 KB Output is correct
98 Correct 181 ms 28236 KB Output is correct
99 Correct 187 ms 28000 KB Output is correct
100 Correct 178 ms 27948 KB Output is correct
101 Correct 179 ms 28008 KB Output is correct
102 Correct 85 ms 27856 KB Output is correct
103 Correct 70 ms 28040 KB Output is correct
104 Correct 85 ms 27984 KB Output is correct
105 Correct 79 ms 27904 KB Output is correct
106 Correct 37 ms 27988 KB Output is correct
107 Incorrect 186 ms 28116 KB Output isn't correct
108 Halted 0 ms 0 KB -