結果
問題 | No.844 split game |
ユーザー | ccppjsrb |
提出日時 | 2020-06-02 17:06:50 |
言語 | Go (1.22.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,339 bytes |
コンパイル時間 | 13,857 ms |
コンパイル使用メモリ | 223,352 KB |
実行使用メモリ | 7,624 KB |
最終ジャッジ日時 | 2024-05-03 06:13:31 |
合計ジャッジ時間 | 16,985 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
5,248 KB |
testcase_01 | AC | 14 ms
5,248 KB |
testcase_02 | AC | 40 ms
5,376 KB |
testcase_03 | AC | 28 ms
5,376 KB |
testcase_04 | AC | 16 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | WA | - |
testcase_43 | AC | 1 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | WA | - |
testcase_46 | AC | 1 ms
5,376 KB |
testcase_47 | AC | 1 ms
5,376 KB |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
ソースコード
package main import ( "bufio" "fmt" "os" "sort" "strconv" ) func getScanner(fp *os.File) *bufio.Scanner { scanner := bufio.NewScanner(fp) scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 1000005), 1000005) return scanner } func getNextString(scanner *bufio.Scanner) string { scanner.Scan() 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 getNextUint64(scanner *bufio.Scanner) uint64 { i, _ := strconv.ParseUint(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 cnt := 0 if os.Getenv("MASPY") == "ますピ" { fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT")) cnt = 3 } if os.Getenv("MASPYPY") == "ますピッピ" { wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10")) } scanner := getScanner(fp) writer := bufio.NewWriter(wfp) solve(scanner, writer) for i := 0; i < cnt; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } writer.Flush() } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { n := getNextInt(scanner) m := getNextInt(scanner) a := cint(getNextInt64(scanner)) dp := make([]cint, n+5) ss := make(splits, m) for i := 0; i < m; i++ { ss[i].l = getNextInt(scanner) ss[i].r = getNextInt(scanner) + 1 ss[i].p = cint(getNextInt64(scanner)) } sort.Sort(ss) done := 0 for i := 1; i < n; i++ { dp[i] -= a } for i := 0; i < m; i++ { for done < ss[i].r { dp[done+1].max(dp[done]) done++ } dp[ss[i].r].max(dp[ss[i].l] + ss[i].p - a) } var ans cint for i := 0; i < n+5; i++ { ans.max(dp[i]) } fmt.Fprintln(writer, ans) } type split struct { l, r int p cint } type splits []split func (a splits) Len() int { return len(a) } func (a splits) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a splits) Less(i, j int) bool { return a[i].r < a[j].r } type cint int64 func (x *cint) min(y cint) *cint { if *x > y { *x = y } return x } func (x *cint) max(y cint) *cint { if *x < y { *x = y } return x }