結果

問題 No.607 開通777年記念
ユーザー tantan
提出日時 2019-06-22 20:40:40
言語 Go
(1.22.1)
結果
AC  
実行時間 503 ms / 2,000 ms
コード長 1,845 bytes
コンパイル時間 11,035 ms
コンパイル使用メモリ 214,136 KB
実行使用メモリ 8,216 KB
最終ジャッジ日時 2023-08-27 03:07:50
合計ジャッジ時間 13,054 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 22 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 457 ms
8,216 KB
testcase_12 AC 503 ms
8,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// https://yukicoder.me/submissions/353490
var isProduct = true

func main() {
	nextReader = newScanner()

	n := nextInt()
	m := nextInt()

	cars := make([]int64, n)
	for i := 0; i < m; i++ {
		debugln(i, "駅目:")

		sums := make([]int64, n)
		inputs := nextInt64s(n)

		for e := 0; e < n; e++ {
			// 0 ~ e車両までの合計乗客
			cars[e] += inputs[e]

			sums[e] = cars[e]
			if e > 0 {
				sums[e] += sums[e-1]
			}

			debugf("0 ~ %d : %d\n", e, sums[e])

			for s := -1; s < e; s++ {
				// s ~ e車両までの合計乗客
				t := sums[e]
				if s > -1 {
					t -= sums[s]
				}

				// debugf("%d ~ %d : %d\n", s, e, t)
				if t == 777 {
					fmt.Println("YES")
					return
				}
			}

		}
	}

	fmt.Println("NO")
}

func debugln(s ...interface{}) {
	if !isProduct {
		fmt.Println(s...)
	}
}

func debug(s ...interface{}) {
	if !isProduct {
		fmt.Print(s...)
	}
}
func debugf(f string, s ...interface{}) {
	if !isProduct {
		fmt.Printf(f, s...)
	}
}

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
	}
}
0