結果
問題 | No.139 交差点 |
ユーザー |
![]() |
提出日時 | 2020-08-16 21:56:54 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,570 bytes |
コンパイル時間 | 12,888 ms |
コンパイル使用メモリ | 220,192 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-11 10:43:30 |
合計ジャッジ時間 | 12,336 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
package mainimport ("bufio""fmt""os""sort""strconv")func out(x ...interface{}) {fmt.Println(x...)}var sc = bufio.NewScanner(os.Stdin)func getInt() int {sc.Scan()i, e := strconv.Atoi(sc.Text())if e != nil {panic(e)}return i}func getInts(N int) []int {ret := make([]int, N)for i := 0; i < N; i++ {ret[i] = getInt()}return ret}func getString() string {sc.Scan()return sc.Text()}// min, max, asub, absなど基本関数func max(a, b int) int {if a > b {return a}return b}func min(a, b int) int {if a < b {return a}return b}func asub(a, b int) int {if a > b {return a - b}return b - a}func abs(a int) int {if a >= 0 {return a}return -a}func lowerBound(a []int, x int) int {idx := sort.Search(len(a), func(i int) bool {return a[i] >= x})return idx}func upperBound(a []int, x int) int {idx := sort.Search(len(a), func(i int) bool {return a[i] > x})return idx}func check(p, x, w, t int) int {ret := 0st := p / trest := t - p%t// out(p, x, w, t, st, rest)if st%2 == 1 { // waitret += restreturn ret}if rest < w {ret += rest + treturn ret}return ret}func main() {sc.Split(bufio.ScanWords)N, L := getInt(), getInt()x := make([]int, N)w := make([]int, N)t := make([]int, N)for i := 0; i < N; i++ {x[i], w[i], t[i] = getInt(), getInt(), getInt()}past := 0pos := 0for i := 0; i < N; i++ {past += x[i] - pospast += check(past, x[i], w[i], t[i])pos = x[i]}past += L - posout(past)}