Skip to content

Commit 2b2d9ba

Browse files
committed
AcWing 第 17 场周赛
1 parent 7ad0886 commit 2b2d9ba

File tree

7 files changed

+179
-0
lines changed

7 files changed

+179
-0
lines changed

misc/acwing/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ Compiler info: go1.13.6, linux, amd64
1919
|[第 13 场周赛](https://www.acwing.com/activity/content/competition/problem_list/65/)|3/3|2|
2020
|[第 14 场周赛](https://www.acwing.com/activity/content/competition/problem_list/68/)|3/3|1|
2121
|[第 15 场周赛](https://www.acwing.com/activity/content/competition/problem_list/69/)|3/3|1|
22+
|[第 16 场周赛](https://www.acwing.com/activity/content/competition/problem_list/70/)|3/3|2|
23+
|[第 17 场周赛](https://www.acwing.com/activity/content/competition/problem_list/71/)|-|-|

misc/acwing/weekly/17/a/a.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
"os"
8+
)
9+
10+
// github.com/EndlessCheng/codeforces-go
11+
func run(_r io.Reader, _w io.Writer) {
12+
in := bufio.NewReader(_r)
13+
out := bufio.NewWriter(_w)
14+
defer out.Flush()
15+
16+
var T, n, k, v int
17+
for Fscan(in, &T); T > 0; T-- {
18+
ans := 100
19+
for Fscan(in, &n, &k); n > 0; n-- {
20+
if Fscan(in, &v); k%v == 0 && k/v < ans {
21+
ans = k / v
22+
}
23+
}
24+
Fprintln(out, ans)
25+
}
26+
}
27+
28+
func main() { run(os.Stdin, os.Stdout) }

misc/acwing/weekly/17/a/a_test.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/acwing/weekly/17/b/b.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
"os"
8+
)
9+
10+
// github.com/EndlessCheng/codeforces-go
11+
func run(_r io.Reader, out io.Writer) {
12+
in := bufio.NewReader(_r)
13+
var n, m, v, ans int
14+
Fscan(in, &n, &m)
15+
cnt := make([][2]int, m)
16+
for ; n > 0; n-- {
17+
c := [2]int{}
18+
for j := 0; j < m; j++ {
19+
Fscan(in, &v)
20+
c[v]++
21+
cnt[j][v]++
22+
}
23+
ans += 1<<c[0] + 1<<c[1] - 2 // 去掉空集
24+
}
25+
for _, c := range cnt {
26+
ans += 1<<c[0] + 1<<c[1] - c[0] - c[1] - 2 // 去掉只有一个元素的集合,以及空集
27+
}
28+
Fprint(out, ans)
29+
}
30+
31+
func main() { run(os.Stdin, os.Stdout) }

misc/acwing/weekly/17/b/b_test.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/acwing/weekly/17/c/c.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
"os"
8+
"sort"
9+
)
10+
11+
// github.com/EndlessCheng/codeforces-go
12+
func run(_r io.Reader, out io.Writer) {
13+
in := bufio.NewReader(_r)
14+
var n, m, ans int
15+
Fscan(in, &n, &m)
16+
a := make([]int, n)
17+
for i := range a {
18+
Fscan(in, &a[i])
19+
}
20+
b := make([]int, m)
21+
for i := range b {
22+
Fscan(in, &b[i])
23+
}
24+
for _, v := range a {
25+
i := sort.SearchInts(b, v)
26+
d := int(2e9)
27+
if i < m {
28+
d = b[i] - v
29+
}
30+
if i > 0 && v-b[i-1] < d {
31+
d = v - b[i-1]
32+
}
33+
if d > ans {
34+
ans = d
35+
}
36+
}
37+
Fprint(out, ans)
38+
}
39+
40+
func main() { run(os.Stdin, os.Stdout) }

misc/acwing/weekly/17/c/c_test.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)