# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
539113 |
2022-03-18T12:22:56 Z |
vector |
Rope (JOI17_rope) |
C++17 |
|
14 ms |
23824 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++)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++)mx=max(B[j]-C[j],mx);
printf("%d\n",N-B[i]-mx);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Correct |
12 ms |
23800 KB |
Output is correct |
4 |
Correct |
12 ms |
23792 KB |
Output is correct |
5 |
Correct |
13 ms |
23824 KB |
Output is correct |
6 |
Correct |
13 ms |
23764 KB |
Output is correct |
7 |
Correct |
14 ms |
23808 KB |
Output is correct |
8 |
Correct |
14 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23812 KB |
Output is correct |
10 |
Correct |
14 ms |
23812 KB |
Output is correct |
11 |
Correct |
12 ms |
23796 KB |
Output is correct |
12 |
Correct |
12 ms |
23804 KB |
Output is correct |
13 |
Correct |
12 ms |
23764 KB |
Output is correct |
14 |
Correct |
12 ms |
23764 KB |
Output is correct |
15 |
Correct |
13 ms |
23764 KB |
Output is correct |
16 |
Correct |
12 ms |
23808 KB |
Output is correct |
17 |
Correct |
13 ms |
23796 KB |
Output is correct |
18 |
Correct |
14 ms |
23728 KB |
Output is correct |
19 |
Correct |
12 ms |
23812 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
12 ms |
23764 KB |
Output is correct |
22 |
Incorrect |
12 ms |
23812 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Correct |
12 ms |
23800 KB |
Output is correct |
4 |
Correct |
12 ms |
23792 KB |
Output is correct |
5 |
Correct |
13 ms |
23824 KB |
Output is correct |
6 |
Correct |
13 ms |
23764 KB |
Output is correct |
7 |
Correct |
14 ms |
23808 KB |
Output is correct |
8 |
Correct |
14 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23812 KB |
Output is correct |
10 |
Correct |
14 ms |
23812 KB |
Output is correct |
11 |
Correct |
12 ms |
23796 KB |
Output is correct |
12 |
Correct |
12 ms |
23804 KB |
Output is correct |
13 |
Correct |
12 ms |
23764 KB |
Output is correct |
14 |
Correct |
12 ms |
23764 KB |
Output is correct |
15 |
Correct |
13 ms |
23764 KB |
Output is correct |
16 |
Correct |
12 ms |
23808 KB |
Output is correct |
17 |
Correct |
13 ms |
23796 KB |
Output is correct |
18 |
Correct |
14 ms |
23728 KB |
Output is correct |
19 |
Correct |
12 ms |
23812 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
12 ms |
23764 KB |
Output is correct |
22 |
Incorrect |
12 ms |
23812 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Correct |
12 ms |
23800 KB |
Output is correct |
4 |
Correct |
12 ms |
23792 KB |
Output is correct |
5 |
Correct |
13 ms |
23824 KB |
Output is correct |
6 |
Correct |
13 ms |
23764 KB |
Output is correct |
7 |
Correct |
14 ms |
23808 KB |
Output is correct |
8 |
Correct |
14 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23812 KB |
Output is correct |
10 |
Correct |
14 ms |
23812 KB |
Output is correct |
11 |
Correct |
12 ms |
23796 KB |
Output is correct |
12 |
Correct |
12 ms |
23804 KB |
Output is correct |
13 |
Correct |
12 ms |
23764 KB |
Output is correct |
14 |
Correct |
12 ms |
23764 KB |
Output is correct |
15 |
Correct |
13 ms |
23764 KB |
Output is correct |
16 |
Correct |
12 ms |
23808 KB |
Output is correct |
17 |
Correct |
13 ms |
23796 KB |
Output is correct |
18 |
Correct |
14 ms |
23728 KB |
Output is correct |
19 |
Correct |
12 ms |
23812 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
12 ms |
23764 KB |
Output is correct |
22 |
Incorrect |
12 ms |
23812 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Correct |
12 ms |
23800 KB |
Output is correct |
4 |
Correct |
12 ms |
23792 KB |
Output is correct |
5 |
Correct |
13 ms |
23824 KB |
Output is correct |
6 |
Correct |
13 ms |
23764 KB |
Output is correct |
7 |
Correct |
14 ms |
23808 KB |
Output is correct |
8 |
Correct |
14 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23812 KB |
Output is correct |
10 |
Correct |
14 ms |
23812 KB |
Output is correct |
11 |
Correct |
12 ms |
23796 KB |
Output is correct |
12 |
Correct |
12 ms |
23804 KB |
Output is correct |
13 |
Correct |
12 ms |
23764 KB |
Output is correct |
14 |
Correct |
12 ms |
23764 KB |
Output is correct |
15 |
Correct |
13 ms |
23764 KB |
Output is correct |
16 |
Correct |
12 ms |
23808 KB |
Output is correct |
17 |
Correct |
13 ms |
23796 KB |
Output is correct |
18 |
Correct |
14 ms |
23728 KB |
Output is correct |
19 |
Correct |
12 ms |
23812 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
12 ms |
23764 KB |
Output is correct |
22 |
Incorrect |
12 ms |
23812 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23764 KB |
Output is correct |
2 |
Correct |
13 ms |
23764 KB |
Output is correct |
3 |
Correct |
12 ms |
23800 KB |
Output is correct |
4 |
Correct |
12 ms |
23792 KB |
Output is correct |
5 |
Correct |
13 ms |
23824 KB |
Output is correct |
6 |
Correct |
13 ms |
23764 KB |
Output is correct |
7 |
Correct |
14 ms |
23808 KB |
Output is correct |
8 |
Correct |
14 ms |
23764 KB |
Output is correct |
9 |
Correct |
12 ms |
23812 KB |
Output is correct |
10 |
Correct |
14 ms |
23812 KB |
Output is correct |
11 |
Correct |
12 ms |
23796 KB |
Output is correct |
12 |
Correct |
12 ms |
23804 KB |
Output is correct |
13 |
Correct |
12 ms |
23764 KB |
Output is correct |
14 |
Correct |
12 ms |
23764 KB |
Output is correct |
15 |
Correct |
13 ms |
23764 KB |
Output is correct |
16 |
Correct |
12 ms |
23808 KB |
Output is correct |
17 |
Correct |
13 ms |
23796 KB |
Output is correct |
18 |
Correct |
14 ms |
23728 KB |
Output is correct |
19 |
Correct |
12 ms |
23812 KB |
Output is correct |
20 |
Correct |
12 ms |
23760 KB |
Output is correct |
21 |
Correct |
12 ms |
23764 KB |
Output is correct |
22 |
Incorrect |
12 ms |
23812 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |