답안 #539130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
539130 2022-03-18T12:54:03 Z vector Rope (JOI17_rope) C++17
55 / 100
2500 ms 32656 KB
#include<bits/stdc++.h>
#define SIZE 1000001
using namespace std;
int N,M,A[SIZE],B[SIZE],C[SIZE],D[SIZE],ans[SIZE];
vector<int>v[SIZE];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin>>N>>M;
    for(int i=1;i<=N;i++){
        cin>>A[i];
        B[A[i]]++;
    }
    for(int i=1;i<=M;i++){
        int mx=0;
        for(int j=1;j<=M;j++)C[j]=0;
        for(int j=1;j<N;j+=2){
            if(A[j]==i||A[j+1]==i)C[A[j]]++,C[A[j+1]]++;
        }
        for(int j=1;j<=M;j++)if(i!=j)mx=max(B[j]-C[j],mx);
        for(int j=1;j<=M;j++)C[j]=0;
        for(int j=2;j<N;j+=2){
            if(A[j]==i||A[j+1]==i)C[A[j]]++,C[A[j+1]]++;
        }
        for(int j=1;j<=M;j++)if(i!=j)mx=max(B[j]-C[j],mx);
        printf("%d\n",N-B[i]-mx);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 11 ms 23764 KB Output is correct
5 Correct 12 ms 23832 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23840 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 12 ms 23808 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 12 ms 23780 KB Output is correct
16 Correct 12 ms 23720 KB Output is correct
17 Correct 12 ms 23740 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 12 ms 23764 KB Output is correct
20 Correct 13 ms 23712 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 12 ms 23756 KB Output is correct
26 Correct 12 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 11 ms 23764 KB Output is correct
5 Correct 12 ms 23832 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23840 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 12 ms 23808 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 12 ms 23780 KB Output is correct
16 Correct 12 ms 23720 KB Output is correct
17 Correct 12 ms 23740 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 12 ms 23764 KB Output is correct
20 Correct 13 ms 23712 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 12 ms 23756 KB Output is correct
26 Correct 12 ms 23764 KB Output is correct
27 Correct 22 ms 24332 KB Output is correct
28 Correct 20 ms 24376 KB Output is correct
29 Correct 22 ms 24320 KB Output is correct
30 Correct 20 ms 24396 KB Output is correct
31 Correct 21 ms 24336 KB Output is correct
32 Correct 22 ms 24404 KB Output is correct
33 Correct 21 ms 24432 KB Output is correct
34 Correct 20 ms 24336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 11 ms 23764 KB Output is correct
5 Correct 12 ms 23832 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23840 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 12 ms 23808 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 12 ms 23780 KB Output is correct
16 Correct 12 ms 23720 KB Output is correct
17 Correct 12 ms 23740 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 12 ms 23764 KB Output is correct
20 Correct 13 ms 23712 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 12 ms 23756 KB Output is correct
26 Correct 12 ms 23764 KB Output is correct
27 Correct 22 ms 24332 KB Output is correct
28 Correct 20 ms 24376 KB Output is correct
29 Correct 22 ms 24320 KB Output is correct
30 Correct 20 ms 24396 KB Output is correct
31 Correct 21 ms 24336 KB Output is correct
32 Correct 22 ms 24404 KB Output is correct
33 Correct 21 ms 24432 KB Output is correct
34 Correct 20 ms 24336 KB Output is correct
35 Correct 67 ms 24524 KB Output is correct
36 Correct 65 ms 24596 KB Output is correct
37 Correct 63 ms 24564 KB Output is correct
38 Correct 63 ms 24592 KB Output is correct
39 Correct 64 ms 24528 KB Output is correct
40 Correct 69 ms 24588 KB Output is correct
41 Correct 63 ms 24592 KB Output is correct
42 Correct 56 ms 24524 KB Output is correct
43 Correct 46 ms 24488 KB Output is correct
44 Correct 65 ms 24548 KB Output is correct
45 Correct 68 ms 24580 KB Output is correct
46 Correct 56 ms 24584 KB Output is correct
47 Correct 49 ms 24576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 11 ms 23764 KB Output is correct
5 Correct 12 ms 23832 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23840 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 12 ms 23808 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 12 ms 23780 KB Output is correct
16 Correct 12 ms 23720 KB Output is correct
17 Correct 12 ms 23740 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 12 ms 23764 KB Output is correct
20 Correct 13 ms 23712 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 12 ms 23756 KB Output is correct
26 Correct 12 ms 23764 KB Output is correct
27 Correct 22 ms 24332 KB Output is correct
28 Correct 20 ms 24376 KB Output is correct
29 Correct 22 ms 24320 KB Output is correct
30 Correct 20 ms 24396 KB Output is correct
31 Correct 21 ms 24336 KB Output is correct
32 Correct 22 ms 24404 KB Output is correct
33 Correct 21 ms 24432 KB Output is correct
34 Correct 20 ms 24336 KB Output is correct
35 Correct 67 ms 24524 KB Output is correct
36 Correct 65 ms 24596 KB Output is correct
37 Correct 63 ms 24564 KB Output is correct
38 Correct 63 ms 24592 KB Output is correct
39 Correct 64 ms 24528 KB Output is correct
40 Correct 69 ms 24588 KB Output is correct
41 Correct 63 ms 24592 KB Output is correct
42 Correct 56 ms 24524 KB Output is correct
43 Correct 46 ms 24488 KB Output is correct
44 Correct 65 ms 24548 KB Output is correct
45 Correct 68 ms 24580 KB Output is correct
46 Correct 56 ms 24584 KB Output is correct
47 Correct 49 ms 24576 KB Output is correct
48 Execution timed out 2556 ms 32656 KB Time limit exceeded
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 11 ms 23764 KB Output is correct
5 Correct 12 ms 23832 KB Output is correct
6 Correct 11 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23840 KB Output is correct
9 Correct 12 ms 23764 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 12 ms 23808 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 12 ms 23764 KB Output is correct
15 Correct 12 ms 23780 KB Output is correct
16 Correct 12 ms 23720 KB Output is correct
17 Correct 12 ms 23740 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 12 ms 23764 KB Output is correct
20 Correct 13 ms 23712 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23764 KB Output is correct
25 Correct 12 ms 23756 KB Output is correct
26 Correct 12 ms 23764 KB Output is correct
27 Correct 22 ms 24332 KB Output is correct
28 Correct 20 ms 24376 KB Output is correct
29 Correct 22 ms 24320 KB Output is correct
30 Correct 20 ms 24396 KB Output is correct
31 Correct 21 ms 24336 KB Output is correct
32 Correct 22 ms 24404 KB Output is correct
33 Correct 21 ms 24432 KB Output is correct
34 Correct 20 ms 24336 KB Output is correct
35 Correct 67 ms 24524 KB Output is correct
36 Correct 65 ms 24596 KB Output is correct
37 Correct 63 ms 24564 KB Output is correct
38 Correct 63 ms 24592 KB Output is correct
39 Correct 64 ms 24528 KB Output is correct
40 Correct 69 ms 24588 KB Output is correct
41 Correct 63 ms 24592 KB Output is correct
42 Correct 56 ms 24524 KB Output is correct
43 Correct 46 ms 24488 KB Output is correct
44 Correct 65 ms 24548 KB Output is correct
45 Correct 68 ms 24580 KB Output is correct
46 Correct 56 ms 24584 KB Output is correct
47 Correct 49 ms 24576 KB Output is correct
48 Execution timed out 2556 ms 32656 KB Time limit exceeded
49 Halted 0 ms 0 KB -