結果
| 問題 | No.59 鉄道の旅 |
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2014-11-07 01:26:30 |
| 言語 | Go (1.26.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 882 bytes |
| 記録 | |
| コンパイル時間 | 12,574 ms |
| コンパイル使用メモリ | 277,048 KB |
| 実行使用メモリ | 16,512 KB |
| 最終ジャッジ日時 | 2026-05-30 14:52:49 |
| 合計ジャッジ時間 | 19,495 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | TLE * 1 -- * 11 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
var scanner = bufio.NewScanner(os.Stdin)
func Scan() (input string) {
if scanner.Scan() {
input = scanner.Text()
}
return
}
func Sign(n int) (int, string) {
if n >= 0 {
return n, "+"
} else {
ns := []byte(strconv.Itoa(n))
n, _ := strconv.Atoi(string(ns[1:]))
return n, "-"
}
}
func Sum(xs ...int) (s int) {
for _, x := range xs {
s += x
}
return
}
func main() {
list := make([]int, 1000001)
NK := strings.Split(Scan(), " ")
N, _ := strconv.Atoi(NK[0])
K, _ := strconv.Atoi(NK[1])
for i := 0; i < N; i++ {
W, _ := strconv.Atoi(Scan())
W, s := Sign(W)
if s == "+" {
if Sum(list[W:]...) < K {
list[W] += 1
}
} else if s == "-" {
if list[W] > 0 {
list[W] -= 1
}
}
}
fmt.Println(Sum(list...))
}
184