結果
問題 | No.1122 Plane Tickets |
ユーザー | ccppjsrb |
提出日時 | 2020-07-24 10:55:09 |
言語 | Go (1.22.1) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 2,313 bytes |
コンパイル時間 | 15,214 ms |
コンパイル使用メモリ | 231,392 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 21:25:46 |
合計ジャッジ時間 | 16,214 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,948 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 1 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 1 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 1 ms
6,940 KB |
testcase_25 | AC | 1 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | AC | 1 ms
6,944 KB |
testcase_30 | AC | 1 ms
6,940 KB |
testcase_31 | AC | 1 ms
6,944 KB |
testcase_32 | AC | 1 ms
6,940 KB |
testcase_33 | AC | 1 ms
6,944 KB |
testcase_34 | AC | 1 ms
6,940 KB |
testcase_35 | AC | 1 ms
6,940 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,940 KB |
testcase_38 | AC | 1 ms
6,944 KB |
testcase_39 | AC | 1 ms
6,944 KB |
testcase_40 | AC | 1 ms
6,940 KB |
testcase_41 | AC | 1 ms
6,944 KB |
testcase_42 | AC | 1 ms
6,940 KB |
testcase_43 | AC | 2 ms
6,940 KB |
testcase_44 | AC | 1 ms
6,944 KB |
testcase_45 | AC | 1 ms
6,944 KB |
testcase_46 | AC | 2 ms
6,944 KB |
testcase_47 | AC | 1 ms
6,940 KB |
testcase_48 | AC | 1 ms
6,940 KB |
testcase_49 | AC | 2 ms
6,944 KB |
testcase_50 | AC | 2 ms
6,940 KB |
testcase_51 | AC | 1 ms
6,940 KB |
testcase_52 | AC | 1 ms
6,940 KB |
testcase_53 | AC | 1 ms
6,940 KB |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 1 ms
6,944 KB |
testcase_56 | AC | 2 ms
6,940 KB |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) func configure(scanner *bufio.Scanner) { scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 1000005), 1000005) } func getNextString(scanner *bufio.Scanner) string { scanned := scanner.Scan() if !scanned { panic("scan failed") } return scanner.Text() } func getNextInt(scanner *bufio.Scanner) int { i, _ := strconv.Atoi(getNextString(scanner)) return i } func getNextInt64(scanner *bufio.Scanner) int64 { i, _ := strconv.ParseInt(getNextString(scanner), 10, 64) return i } func getNextFloat64(scanner *bufio.Scanner) float64 { i, _ := strconv.ParseFloat(getNextString(scanner), 64) return i } func main() { fp := os.Stdin wfp := os.Stdout extra := 0 if os.Getenv("I") == "IronMan" { fp, _ = os.Open(os.Getenv("END_GAME")) extra = 100 } scanner := bufio.NewScanner(fp) configure(scanner) writer := bufio.NewWriter(wfp) defer func() { r := recover() if r != nil { fmt.Fprintln(writer, r) } writer.Flush() }() solve(scanner, writer) for i := 0; i < extra; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { n := 5 tickets := make([]int64, n) for i := 0; i < n; i++ { tickets[i] = getNextInt64(scanner) } var l, r int64 l = -1 r = int64(1e16) for l+1 < r { m := (l + r) >> 1 if enable(m, tickets) { l = m continue } r = m } fmt.Fprintln(writer, l) } func enable(m int64, tickets []int64) bool { n := 5 tt := make([]int64, n) for i := 0; i < n; i++ { tt[i] = tickets[i] - m } return check(m, tt) } func check(m int64, tt []int64) bool { n := len(tt) for i := 0; i < n; i++ { if need(tt[i], tt[(i+1)%n], tt[(i+2)%n], tt[(i+3)%n], tt[(i+4)%n]) <= m { return true } } return false } func need(a, b, c, d, e int64) int64 { var ans int64 f := -min(0, a) + min(0, b) - min(0, c) + min(0, d) - min(0, e) if f < 0 { f = 0 } f = (f + 1) >> 1 ans += f a, e = a+f, e+f ans += -min(0, a) a, b = 0, b-min(0, a) ans += -min(0, b) b, c = 0, c-min(0, b) ans += -min(0, c) c, d = 0, d-min(0, c) ans += -min(0, d) d, e = 0, e-min(0, d) ans += -min(0, e) e, a = 0, a-min(0, e) return ans } func min(a, b int64) int64 { if a < b { return a } return b }