Submission #67364858
Source Code Expand
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
func main() {
sc := bufio.NewScanner(os.Stdin)
sc.Buffer(make([]byte, 1000000), 100000000)
sc.Scan()
T, _ := strconv.Atoi(sc.Text())
for i := 0; i < T; i++ {
sc.Scan()
N, _ := strconv.Atoi(sc.Text())
sc.Scan()
strS := strings.Fields(sc.Text())
S := make([]int, len(strS))
for i, v := range strS {
S[i], _ = strconv.Atoi(v)
}
solve(N, S)
}
}
func solve(N int, S []int) {
sort.Slice(S, func(i, j int) bool {
if i == 0 || j == len(S)-1 {
return true
}
if j == 0 || i == len(S)-1 {
return false
}
return S[i] < S[j]
})
// ドミノ1を選ぶのは確定
count := 1
pre := S[0]
for i := 1; i < N-1; i++ {
// ドミノiを選ぶ条件
// - preがドミノiを倒せること
if 2*pre < S[i] {
break
}
// - preがドミノi+1を倒せないこと
if S[i+1] <= 2*pre {
continue
}
// - preがドミノNを倒せないこと
if S[len(S)-1] <= 2*pre {
break
}
pre = S[i]
count++
}
// ドミノNを選べるかどうかの判定
if S[len(S)-1] <= 2*pre {
fmt.Println(count + 1)
} else {
fmt.Println(-1)
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Giant Domino |
| User | integral |
| Language | Go (go 1.20.6) |
| Score | 0 |
| Code Size | 1247 Byte |
| Status | WA |
| Exec Time | 149 ms |
| Memory | 11504 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt |
| All | 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 03_corner_00.txt, 03_corner_01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 1600 KiB |
| 01_small_00.txt | AC | 64 ms | 5844 KiB |
| 01_small_01.txt | AC | 63 ms | 5828 KiB |
| 01_small_02.txt | AC | 46 ms | 5556 KiB |
| 01_small_03.txt | AC | 149 ms | 6388 KiB |
| 01_small_04.txt | AC | 104 ms | 6352 KiB |
| 01_small_05.txt | AC | 81 ms | 6368 KiB |
| 01_small_06.txt | AC | 68 ms | 6372 KiB |
| 01_small_07.txt | AC | 41 ms | 6312 KiB |
| 01_small_08.txt | WA | 32 ms | 6316 KiB |
| 02_random_00.txt | AC | 20 ms | 6436 KiB |
| 02_random_01.txt | AC | 41 ms | 11504 KiB |
| 02_random_02.txt | AC | 40 ms | 11500 KiB |
| 02_random_03.txt | WA | 28 ms | 8908 KiB |
| 02_random_04.txt | AC | 40 ms | 11504 KiB |
| 02_random_05.txt | WA | 35 ms | 9748 KiB |
| 02_random_06.txt | WA | 36 ms | 9964 KiB |
| 02_random_07.txt | WA | 36 ms | 9964 KiB |
| 02_random_08.txt | WA | 32 ms | 8960 KiB |
| 02_random_09.txt | WA | 36 ms | 9968 KiB |
| 02_random_10.txt | WA | 36 ms | 9952 KiB |
| 02_random_11.txt | WA | 31 ms | 7448 KiB |
| 02_random_12.txt | WA | 36 ms | 9944 KiB |
| 02_random_13.txt | WA | 36 ms | 9964 KiB |
| 02_random_14.txt | WA | 31 ms | 8932 KiB |
| 02_random_15.txt | WA | 36 ms | 9964 KiB |
| 02_random_16.txt | WA | 36 ms | 9944 KiB |
| 02_random_17.txt | WA | 33 ms | 9092 KiB |
| 02_random_18.txt | WA | 36 ms | 9964 KiB |
| 02_random_19.txt | WA | 36 ms | 9968 KiB |
| 03_corner_00.txt | WA | 0 ms | 1608 KiB |
| 03_corner_01.txt | WA | 1 ms | 1600 KiB |