Language: C++


AtCoder Regular Contest 103
 English 
 bingxuan9112 (Guest) 
Contest Duration: 2018-09-29(Sat) 20:00 ~ 2018-09-29(Sat) 21:40 (local time) Back to Home
 Top
 Tasks
 Clarifications
 Submit
 Submissions
 Standings
 Custom Test
 Editorial
C - /\/\/\/
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 
300
300 points

Problem Statement
A sequence 
a
1
,
a
2
,
.
.
.
,
a
n
a1,a2,...,an is said to be /\/\/\/ when the following conditions are satisfied:

For each 
i
=
1
,
2
,
.
.
.
,
n
−
2
i=1,2,...,n−2, 
a
i
=
a
i
+
2
ai=ai+2.
Exactly two different numbers appear in the sequence.
You are given a sequence 
v
1
,
v
2
,
.
.
.
,
v
n
v1,v2,...,vn whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.

Constraints
2
≤
n
≤
10
5
2≤n≤105
n
n is even.
1
≤
v
i
≤
10
5
1≤vi≤105
v
i
vi is an integer.
Input
Input is given from Standard Input in the following format:

n
n
v
1
v1 
v
2
v2 
.
.
.
... 
v
n
vn
Output
Print the minimum number of elements that needs to be replaced.

Sample Input 1 Copy
Copy
4
3 1 3 2
Sample Output 1 Copy
Copy
1
The sequence 
3
,
1
,
3
,
2
3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 
3
,
1
,
3
,
1
3,1,3,1.

Sample Input 2 Copy
Copy
6
105 119 105 119 105 119
Sample Output 2 Copy
Copy
0
The sequence 
105
,
119
,
105
,
119
,
105
,
119
105,119,105,119,105,119 is /\/\/\/.

Sample Input 3 Copy
Copy
4
1 1 1 1
Sample Output 3 Copy
Copy
2
The elements of the sequence 
1
,
1
,
1
,
1
1,1,1,1 are all the same, so it is not /\/\/\/.

Language
C++14 (GCC 5.4.1)
Source Code

1
​
※ at most 512 KiB
※ Your source code will be saved as Main.extension.

   Open File

Toggle Editor

Auto Height

Submit
FacebookTwitterTelegram分享
Rule Glossary
Terms of service Privacy Policy Information Protection Policy Company FAQ Contact
Copyright Since 2012 ©AtCoder Inc. All rights reserved.

Compiler output:
a.cc:5:24: error: invalid digit "9" in octal constant
    5 | Contest Duration: 2018-09-29(Sat) 20:00 ~ 2018-09-29(Sat) 21:40 (local time) Back to Home
      |                        ^~
a.cc:5:48: error: invalid digit "9" in octal constant
    5 | Contest Duration: 2018-09-29(Sat) 20:00 ~ 2018-09-29(Sat) 21:40 (local time) Back to Home
      |                                                ^~
a.cc:14:6: error: stray '\' in program
   14 | C - /\/\/\/
      |      ^
a.cc:14:8: error: stray '\' in program
   14 | C - /\/\/\/
      |        ^
a.cc:14:10: error: stray '\' in program
   14 | C - /\/\/\/
      |          ^
a.cc:35:29: error: stray '\' in program
   35 | a1,a2,...,an is said to be /\/\/\/ when the following conditions are satisfied:
      |                             ^
a.cc:35:31: error: stray '\' in program
   35 | a1,a2,...,an is said to be /\/\/\/ when the following conditions are satisfied:
      |                               ^
a.cc:35:33: error: stray '\' in program
   35 | a1,a2,...,an is said to be /\/\/\/ when the following conditions are satisfied:
      |                                 ^
a.cc:49:1: error: extended character − is not valid in an identifier
   49 | −
      | ^
a.cc:51:11: error: extended character − is not valid in an identifier
   51 | i=1,2,...,n−2,
      |           ^
a.cc:74:73: error: stray '\' in program
   74 | v1,v2,...,vn whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
      |                                                                         ^
a.cc:74:75: error: stray '\' in program
   74 | v1,v2,...,vn whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
      |                                                                           ^
a.cc:74:77: error: stray '\' in program
   74 | v1,v2,...,vn whose length is even. We would like to make this sequence /\/\/\/ by replacing some of its elements. Find the minimum number of elements that needs to be replaced.
      |                                                                             ^
a.cc:78:1: error: extended character ≤ is not valid in an identifier
   78 | ≤
      | ^
a.cc:80:1: error: extended character ≤ is not valid in an identifier
   80 | ≤
      | ^
a.cc:83:1: error: extended character ≤ is not valid in an identifier
   83 | 2≤n≤105
      | ^
a.cc:83:1: error: extended character ≤ is not valid in an identifier
a.cc:87:1: error: extended character ≤ is not valid in an identifier
   87 | ≤
      | ^
a.cc:90:1: error: extended character ≤ is not valid in an identifier
   90 | ≤
      | ^
a.cc:93:1: error: extended character ≤ is not valid in an identifier
   93 | 1≤vi≤105
      | ^
a.cc:93:1: error: extended character ≤ is not valid in an identifier
a.cc:133:17: error: stray '\' in program
  133 | 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it
      |                 ^
a.cc:133:19: error: stray '\' in program
  133 | 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it
      |                   ^
a.cc:133:21: error: stray '\' in program
  133 | 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it
      |                     ^
a.cc:133:45: error: stray '\' in program
  133 | 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it
      |                                             ^
a.cc:133:47: error: stray '\' in program
  133 | 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it
      |                                               ^
a.cc:133:49: error: stray '\' in program
  133 | 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it
      |                                                 ^
a.cc:162:29: error: stray '\' in program
  162 | 105,119,105,119,105,119 is /\/\/\/.
      |                             ^
a.cc:162:31: error: stray '\' in program
  162 | 105,119,105,119,105,119 is /\/\/\/.
      |                               ^
a.cc:162:33: error: stray '\' in program
  162 | 105,119,105,119,105,119 is /\/\/\/.
      |                                 ^
a.cc:179:41: error: stray '\' in program
  179 | 1,1,1,1 are all the same, so it is not /\/\/\/.
      |                                         ^
a.cc:179:43: error: stray '\' in program
  179 | 1,1,1,1 are all the same, so it is not /\/\/\/.
      |                                           ^
a.cc:179:45: error: stray '\' in program
  179 | 1,1,1,1 are all the same, so it is not /\/\/\/.
      |                                             ^
a.cc:182:12: error: too many decimal points in number
  182 | C++14 (GCC 5.4.1)
      |            ^~~~~
a.cc:187:1: error: extended character ※ is not valid in an identifier
  187 | ※ at most 512 KiB
      | ^
a.cc:188:1: error: extended character ※ is not valid in an identifier
  188 | ※ Your source code will be saved as Main.extension.
      | ^
a.cc:200:22: error: extended character © is not valid in an identifier
  200 | Copyright Since 2012 ©AtCoder Inc. All rights reserved.
      |                      ^
a.cc:2:1: error: 'AtCoder' does not name a type
    2 | AtCoder Regular Contest 103
      | ^~~~~~~