結果
問題 | No.139 交差点 |
ユーザー |
|
提出日時 | 2016-03-05 13:56:10 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 692 bytes |
コンパイル時間 | 11,466 ms |
コンパイル使用メモリ | 223,008 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 23:36:52 |
合計ジャッジ時間 | 12,595 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
package mainimport ("bufio""fmt""os""strconv")var sc = bufio.NewScanner(os.Stdin)var rdr = bufio.NewReaderSize(os.Stdin, 1000000)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, 0for _, v := range ns {x, w, c := v[0], v[1], v[2]t += x - rr += x - rdiv, mod := t/c, t%cif div%2 == 1 {t += c - mod} else if w > c-mod {t += c - mod + c}t += wr += w}fmt.Println(t + l - r)}func nextLine() string {sc.Scan()return sc.Text()}func nextInt() int {i, _ := strconv.Atoi(nextLine())return i}