답안 #810196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810196 2023-08-06T06:22:49 Z boyliguanhan 벽 칠하기 (APIO20_paint) C++17
28 / 100
1500 ms 10484 KB
#include "paint.h"

#include <bits/stdc++.h>
using namespace std;
int lseg1[200100], lseg2[200100];
vector<int> liked_by[200100];
int dp[200100]{}, valid_i[200100]{};
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
    for(int i = 0; i < K; i++) liked_by[i].clear();
    multiset<int> st;
    for(int i = 0; i < M; i++)
        for(int color: B[i])
            liked_by[color].push_back(i);
    for(int i = N; i--;) {
        for(auto j: liked_by[C[i]]) {
            lseg1[j] = 1+lseg2[(j+1)%M];
            if(lseg1[j]>=M) valid_i[i]=1;
        }
        swap(lseg1, lseg2);
        for(auto j:liked_by[C[i+1]])
            lseg1[j]=0;
    }
    for(int i = 0; i < M; i++) st.insert(0);
    for(int i = N; i--;) {
        dp[i]=1e9;
        if(valid_i[i])
            dp[i] = 1+*st.begin();
        st.insert(dp[i]);
        st.erase(st.find(dp[i+M]));
    }
    return (dp[0]<1e9?dp[0]:-1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 4 ms 6520 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 3 ms 6516 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 67 ms 6564 KB Output is correct
8 Correct 66 ms 6552 KB Output is correct
9 Correct 65 ms 6484 KB Output is correct
10 Correct 71 ms 6552 KB Output is correct
11 Correct 66 ms 6552 KB Output is correct
12 Correct 72 ms 6568 KB Output is correct
13 Correct 66 ms 6604 KB Output is correct
14 Correct 67 ms 6592 KB Output is correct
15 Correct 69 ms 6592 KB Output is correct
16 Correct 67 ms 6588 KB Output is correct
17 Correct 68 ms 6592 KB Output is correct
18 Correct 67 ms 6612 KB Output is correct
19 Correct 66 ms 6612 KB Output is correct
20 Correct 68 ms 6612 KB Output is correct
21 Correct 68 ms 6616 KB Output is correct
22 Correct 80 ms 10484 KB Output is correct
23 Correct 79 ms 10484 KB Output is correct
24 Correct 79 ms 10452 KB Output is correct
25 Execution timed out 1572 ms 6864 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6484 KB Output is correct
2 Correct 4 ms 6520 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 3 ms 6516 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 67 ms 6564 KB Output is correct
8 Correct 66 ms 6552 KB Output is correct
9 Correct 65 ms 6484 KB Output is correct
10 Correct 71 ms 6552 KB Output is correct
11 Correct 66 ms 6552 KB Output is correct
12 Correct 72 ms 6568 KB Output is correct
13 Correct 66 ms 6604 KB Output is correct
14 Correct 67 ms 6592 KB Output is correct
15 Correct 69 ms 6592 KB Output is correct
16 Correct 67 ms 6588 KB Output is correct
17 Correct 68 ms 6592 KB Output is correct
18 Correct 67 ms 6612 KB Output is correct
19 Correct 66 ms 6612 KB Output is correct
20 Correct 68 ms 6612 KB Output is correct
21 Correct 68 ms 6616 KB Output is correct
22 Correct 6 ms 6484 KB Output is correct
23 Correct 4 ms 6484 KB Output is correct
24 Correct 3 ms 6484 KB Output is correct
25 Correct 3 ms 6484 KB Output is correct
26 Correct 3 ms 6484 KB Output is correct
27 Correct 39 ms 6560 KB Output is correct
28 Correct 45 ms 6568 KB Output is correct
29 Correct 36 ms 6484 KB Output is correct
30 Correct 47 ms 6564 KB Output is correct
31 Correct 62 ms 6548 KB Output is correct
32 Correct 51 ms 6484 KB Output is correct
33 Correct 55 ms 6484 KB Output is correct
34 Correct 59 ms 6584 KB Output is correct
35 Correct 39 ms 6584 KB Output is correct
36 Correct 51 ms 6588 KB Output is correct
37 Correct 46 ms 6592 KB Output is correct
38 Correct 42 ms 6484 KB Output is correct
39 Correct 43 ms 6568 KB Output is correct
40 Correct 45 ms 6612 KB Output is correct
41 Correct 42 ms 6484 KB Output is correct
42 Correct 57 ms 6592 KB Output is correct
43 Correct 43 ms 6564 KB Output is correct
44 Correct 68 ms 6560 KB Output is correct
45 Correct 66 ms 6556 KB Output is correct
46 Correct 65 ms 6556 KB Output is correct
47 Correct 68 ms 6560 KB Output is correct
48 Correct 66 ms 6564 KB Output is correct
49 Correct 76 ms 6560 KB Output is correct
50 Correct 68 ms 6596 KB Output is correct
51 Correct 69 ms 6592 KB Output is correct
52 Correct 71 ms 6588 KB Output is correct
53 Correct 73 ms 6588 KB Output is correct
54 Correct 66 ms 6604 KB Output is correct
55 Correct 78 ms 6592 KB Output is correct
56 Correct 68 ms 6612 KB Output is correct
57 Correct 66 ms 6596 KB Output is correct
58 Correct 75 ms 6604 KB Output is correct
59 Correct 66 ms 6580 KB Output is correct
60 Correct 66 ms 6612 KB Output is correct
61 Correct 66 ms 6580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6484 KB Output is correct
2 Correct 4 ms 6484 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 4 ms 6520 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6516 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 3 ms 6484 KB Output is correct
9 Correct 67 ms 6564 KB Output is correct
10 Correct 66 ms 6552 KB Output is correct
11 Correct 65 ms 6484 KB Output is correct
12 Correct 71 ms 6552 KB Output is correct
13 Correct 66 ms 6552 KB Output is correct
14 Correct 72 ms 6568 KB Output is correct
15 Correct 66 ms 6604 KB Output is correct
16 Correct 67 ms 6592 KB Output is correct
17 Correct 69 ms 6592 KB Output is correct
18 Correct 67 ms 6588 KB Output is correct
19 Correct 68 ms 6592 KB Output is correct
20 Correct 67 ms 6612 KB Output is correct
21 Correct 66 ms 6612 KB Output is correct
22 Correct 68 ms 6612 KB Output is correct
23 Correct 68 ms 6616 KB Output is correct
24 Correct 80 ms 10484 KB Output is correct
25 Correct 79 ms 10484 KB Output is correct
26 Correct 79 ms 10452 KB Output is correct
27 Correct 3 ms 6484 KB Output is correct
28 Correct 3 ms 6484 KB Output is correct
29 Correct 3 ms 6484 KB Output is correct
30 Correct 39 ms 6560 KB Output is correct
31 Correct 45 ms 6568 KB Output is correct
32 Correct 36 ms 6484 KB Output is correct
33 Correct 47 ms 6564 KB Output is correct
34 Correct 62 ms 6548 KB Output is correct
35 Correct 51 ms 6484 KB Output is correct
36 Correct 55 ms 6484 KB Output is correct
37 Correct 59 ms 6584 KB Output is correct
38 Correct 39 ms 6584 KB Output is correct
39 Correct 51 ms 6588 KB Output is correct
40 Correct 46 ms 6592 KB Output is correct
41 Correct 42 ms 6484 KB Output is correct
42 Correct 43 ms 6568 KB Output is correct
43 Correct 45 ms 6612 KB Output is correct
44 Correct 42 ms 6484 KB Output is correct
45 Correct 57 ms 6592 KB Output is correct
46 Correct 43 ms 6564 KB Output is correct
47 Correct 68 ms 6560 KB Output is correct
48 Correct 66 ms 6556 KB Output is correct
49 Correct 65 ms 6556 KB Output is correct
50 Correct 68 ms 6560 KB Output is correct
51 Correct 66 ms 6564 KB Output is correct
52 Correct 76 ms 6560 KB Output is correct
53 Correct 68 ms 6596 KB Output is correct
54 Correct 69 ms 6592 KB Output is correct
55 Correct 71 ms 6588 KB Output is correct
56 Correct 73 ms 6588 KB Output is correct
57 Correct 66 ms 6604 KB Output is correct
58 Correct 78 ms 6592 KB Output is correct
59 Correct 68 ms 6612 KB Output is correct
60 Correct 66 ms 6596 KB Output is correct
61 Correct 75 ms 6604 KB Output is correct
62 Correct 66 ms 6580 KB Output is correct
63 Correct 66 ms 6612 KB Output is correct
64 Correct 66 ms 6580 KB Output is correct
65 Correct 36 ms 6584 KB Output is correct
66 Correct 63 ms 6568 KB Output is correct
67 Correct 66 ms 6588 KB Output is correct
68 Correct 66 ms 6564 KB Output is correct
69 Correct 70 ms 6572 KB Output is correct
70 Correct 58 ms 6748 KB Output is correct
71 Correct 57 ms 6740 KB Output is correct
72 Correct 56 ms 6744 KB Output is correct
73 Correct 57 ms 6660 KB Output is correct
74 Correct 51 ms 6740 KB Output is correct
75 Correct 50 ms 6740 KB Output is correct
76 Correct 55 ms 9216 KB Output is correct
77 Correct 59 ms 9648 KB Output is correct
78 Correct 62 ms 10060 KB Output is correct
79 Correct 67 ms 6576 KB Output is correct
80 Correct 73 ms 6580 KB Output is correct
81 Correct 66 ms 6484 KB Output is correct
82 Correct 70 ms 6584 KB Output is correct
83 Correct 67 ms 6584 KB Output is correct
84 Correct 79 ms 6792 KB Output is correct
85 Correct 68 ms 6784 KB Output is correct
86 Correct 69 ms 6784 KB Output is correct
87 Correct 68 ms 6788 KB Output is correct
88 Correct 67 ms 6796 KB Output is correct
89 Correct 79 ms 6796 KB Output is correct
90 Correct 87 ms 10300 KB Output is correct
91 Correct 83 ms 10284 KB Output is correct
92 Correct 88 ms 10308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6484 KB Output is correct
2 Correct 4 ms 6484 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 4 ms 6520 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6516 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 3 ms 6484 KB Output is correct
9 Correct 67 ms 6564 KB Output is correct
10 Correct 66 ms 6552 KB Output is correct
11 Correct 65 ms 6484 KB Output is correct
12 Correct 71 ms 6552 KB Output is correct
13 Correct 66 ms 6552 KB Output is correct
14 Correct 72 ms 6568 KB Output is correct
15 Correct 66 ms 6604 KB Output is correct
16 Correct 67 ms 6592 KB Output is correct
17 Correct 69 ms 6592 KB Output is correct
18 Correct 67 ms 6588 KB Output is correct
19 Correct 68 ms 6592 KB Output is correct
20 Correct 67 ms 6612 KB Output is correct
21 Correct 66 ms 6612 KB Output is correct
22 Correct 68 ms 6612 KB Output is correct
23 Correct 68 ms 6616 KB Output is correct
24 Correct 80 ms 10484 KB Output is correct
25 Correct 79 ms 10484 KB Output is correct
26 Correct 79 ms 10452 KB Output is correct
27 Execution timed out 1572 ms 6864 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6484 KB Output is correct
2 Correct 4 ms 6484 KB Output is correct
3 Correct 3 ms 6484 KB Output is correct
4 Correct 4 ms 6520 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6516 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 3 ms 6484 KB Output is correct
9 Correct 67 ms 6564 KB Output is correct
10 Correct 66 ms 6552 KB Output is correct
11 Correct 65 ms 6484 KB Output is correct
12 Correct 71 ms 6552 KB Output is correct
13 Correct 66 ms 6552 KB Output is correct
14 Correct 72 ms 6568 KB Output is correct
15 Correct 66 ms 6604 KB Output is correct
16 Correct 67 ms 6592 KB Output is correct
17 Correct 69 ms 6592 KB Output is correct
18 Correct 67 ms 6588 KB Output is correct
19 Correct 68 ms 6592 KB Output is correct
20 Correct 67 ms 6612 KB Output is correct
21 Correct 66 ms 6612 KB Output is correct
22 Correct 68 ms 6612 KB Output is correct
23 Correct 68 ms 6616 KB Output is correct
24 Correct 80 ms 10484 KB Output is correct
25 Correct 79 ms 10484 KB Output is correct
26 Correct 79 ms 10452 KB Output is correct
27 Execution timed out 1572 ms 6864 KB Time limit exceeded
28 Halted 0 ms 0 KB -