結果
| 問題 |
No.139 交差点
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-05 14:00:41 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 637 bytes |
| コンパイル時間 | 11,379 ms |
| コンパイル使用メモリ | 223,660 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 23:37:09 |
| 合計ジャッジ時間 | 11,922 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
var sc = bufio.NewScanner(os.Stdin)
func main() {
sc.Split(bufio.ScanWords)
n, l := nextInt(), nextInt()
ns := make([][3]int, n)
for i := 0; i < n; i++ {
ns[i] = [3]int{nextInt(), nextInt(), nextInt()}
}
t, r := 0, 0
for _, v := range ns {
x, w, c := v[0], v[1], v[2]
t, r = t+x-r, x
div, mod := t/c, t%c
if div%2 == 1 {
t += c - mod
} else if w > c-mod {
t += c - mod + c
}
t, r = t+w, r+w
}
fmt.Println(t + l - r)
}
func nextLine() string {
sc.Scan()
return sc.Text()
}
func nextInt() int {
i, _ := strconv.Atoi(nextLine())
return i
}