Skip to content

Commit a0aa475

Browse files
committed
cf862A
1 parent 751b428 commit a0aa475

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

main/800-899/862A.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
. "fmt"
5+
"io"
6+
)
7+
8+
// https://github.com/EndlessCheng
9+
func cf862A(in io.Reader, out io.Writer) {
10+
var n, x, v, ans int
11+
Fscan(in, &n, &x)
12+
has := make([]bool, x)
13+
for range n {
14+
Fscan(in, &v)
15+
if v < x {
16+
has[v] = true
17+
} else if v == x {
18+
ans++
19+
}
20+
}
21+
for _, b := range has {
22+
if !b {
23+
ans++
24+
}
25+
}
26+
Fprint(out, ans)
27+
}
28+
29+
//func main() { cf862A(os.Stdin, os.Stdout) }

main/800-899/862A_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Generated by copypasta/template/generator_test.go
2+
package main
3+
4+
import (
5+
"github.com/EndlessCheng/codeforces-go/main/testutil"
6+
"testing"
7+
)
8+
9+
// https://codeforces.com/problemset/problem/862/A
10+
// https://codeforces.com/problemset/status/862/problem/A?friends=on
11+
func Test_cf862A(t *testing.T) {
12+
testCases := [][2]string{
13+
{
14+
`5 3
15+
0 4 5 6 7`,
16+
`2`,
17+
},
18+
{
19+
`1 0
20+
0`,
21+
`1`,
22+
},
23+
{
24+
`5 0
25+
1 2 3 4 5`,
26+
`0`,
27+
},
28+
}
29+
testutil.AssertEqualStringCase(t, testCases, 0, cf862A)
30+
}

0 commit comments

Comments
 (0)