結果
問題 | No.865 24時間降水量 |
ユーザー |
![]() |
提出日時 | 2020-06-09 18:14:30 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 2,621 bytes |
コンパイル時間 | 16,949 ms |
コンパイル使用メモリ | 248,636 KB |
実行使用メモリ | 14,080 KB |
最終ジャッジ日時 | 2025-01-02 13:36:50 |
合計ジャッジ時間 | 19,191 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
package mainimport ("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.Stdinwfp := os.Stdoutextra := 0if 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 := getNextInt(scanner)aa := make([]int, n)ss := make([]int, n+1)for i := 0; i < n; i++ {aa[i] = getNextInt(scanner)ss[i+1] = ss[i] + aa[i]}s24 := make([]int, 0)var ans cintfor i := 24; i < n+1; i++ {s24 = append(s24, ss[i]-ss[i-24])ans.maxAs(ss[i] - ss[i-24])}q := getNextInt(scanner)for i := 0; i < q; i++ {t := getNextInt(scanner) - 1v := getNextInt(scanner)for j := t - 23; j < t+1 && j < len(s24); j++ {if j < 0 {continue}s24[j] += v - aa[t]ans.maxAs(s24[j])}aa[t] = vfmt.Fprintln(writer, ans)}}type cint intfunc (ct *cint) cintize(x interface{}) cint {if y, isCint := x.(cint); isCint {return y}if y, isInt64 := x.(int64); isInt64 {return cint(y)}return cint(x.(int))}func (ct *cint) minAs(x interface{}) *cint {*ct = ct.min(x)return ct}func (ct *cint) maxAs(x interface{}) *cint {*ct = ct.max(x)return ct}func (ct cint) min(x interface{}) cint {y := ct.cintize(x)if ct > y {return y}return ct}func (ct cint) max(x interface{}) cint {y := ct.cintize(x)if ct < y {return y}return ct}func (ct cint) add(x interface{}) cint {return ct + ct.cintize(x)}func (ct cint) sub(x interface{}) cint {return ct - ct.cintize(x)}func (ct cint) mul(x interface{}) cint {return ct * ct.cintize(x)}func (ct cint) div(x interface{}) cint {return ct / ct.cintize(x)}