結果

問題 No.561 東京と京都
ユーザー tsuchinagatsuchinaga
提出日時 2019-06-25 13:19:28
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 11,235 ms
コンパイル使用メモリ 203,236 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 03:07:42
合計ジャッジ時間 12,284 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func main() {
	var n, d, t, k, inT, inK, tmpT, tmpK int // 日数、交通費、東京報酬、京都報酬、最大東京収益、最大京都収益、東京計算用、京都計算用
	_, _ = fmt.Scan(&n, &d)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	inK = -d // 最初は東京にいるので、京都に居るという場合は東京から移動した後ということになる
	for i := 0; i < n; i++ {
		sc.Scan()
		t, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ = strconv.Atoi(sc.Text())

		tmpT = inT
		if inT < inK-d {
			tmpT = inK - d
		}

		tmpK = inK
		if inK < inT-d {
			tmpK = inT - d
		}

		inT = tmpT + t
		inK = tmpK + k
	}

	if inT < inK {
		fmt.Println(inK)
	} else {
		fmt.Println(inT)
	}
}
0