結果
| 問題 |
No.607 開通777年記念
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-06-22 18:54:11 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,730 bytes |
| コンパイル時間 | 16,998 ms |
| コンパイル使用メモリ | 235,592 KB |
| 実行使用メモリ | 19,072 KB |
| 最終ジャッジ日時 | 2024-12-26 09:41:12 |
| 合計ジャッジ時間 | 20,202 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 6 WA * 4 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
nextReader = newScanner()
n := nextInt()
m := nextInt()
dp := make([][]int64, n)
for i := 0; i < n; i++ {
dp[i] = make([]int64, n)
}
// i = i駅
for i := 0; i < m; i++ {
a := nextInt64s(n)
// j = j両
for j := 0; j < n; j++ {
if i == 0 {
dp[i][j] = 0
continue
}
dp[i][j] = dp[i-1][j] + a[j]
if dp[i][j] == 777 {
fmt.Println("YES")
return
}
}
}
// for i := 0; i < m; i++ {
// // j = j両
// fmt.Print(i, ": ")
// for j := 0; j < n; j++ {
// fmt.Print(dp[i][j])
// fmt.Print(" ")
// }
// fmt.Println("")
// }
for i := 0; i < m; i++ {
for s := 0; s < n; s++ {
for e := 0; e < n; e++ {
// i駅目のs車両~e車両の人の数
sum := dp[i][s] + dp[i][e]
if sum == 777 {
fmt.Println("YES")
return
}
}
}
}
fmt.Println("NO")
}
var nextReader func() string
func newScanner() func() string {
r := bufio.NewScanner(os.Stdin)
r.Buffer(make([]byte, 1024), int(1e+11))
r.Split(bufio.ScanWords)
return func() string {
r.Scan()
return r.Text()
}
}
func nextString() string {
return nextReader()
}
func nextInt64() int64 {
v, _ := strconv.ParseInt(nextReader(), 10, 64)
return v
}
func nextInt() int {
v, _ := strconv.Atoi(nextReader())
return v
}
func nextInts(n int) []int {
r := make([]int, n)
for i := 0; i < n; i++ {
r[i] = nextInt()
}
return r
}
func nextInt64s(n int) []int64 {
r := make([]int64, n)
for i := 0; i < n; i++ {
r[i] = nextInt64()
}
return r
}
func nextFloat64() float64 {
f, _ := strconv.ParseFloat(nextReader(), 64)
return f
}
func maxInt(a, b int) int {
if a > b {
return a
} else {
return b
}
}