結果
問題 | No.1705 Mode of long array |
ユーザー | 小野寺健 |
提出日時 | 2021-12-17 10:09:42 |
言語 | Go (1.22.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,290 bytes |
コンパイル時間 | 10,626 ms |
コンパイル使用メモリ | 201,220 KB |
実行使用メモリ | 20,964 KB |
最終ジャッジ日時 | 2023-10-12 11:38:19 |
合計ジャッジ時間 | 63,052 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 1 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 21 ms
4,352 KB |
testcase_04 | AC | 18 ms
4,352 KB |
testcase_05 | AC | 24 ms
4,352 KB |
testcase_06 | AC | 76 ms
4,352 KB |
testcase_07 | AC | 94 ms
4,352 KB |
testcase_08 | AC | 92 ms
4,348 KB |
testcase_09 | AC | 79 ms
4,352 KB |
testcase_10 | AC | 76 ms
4,352 KB |
testcase_11 | AC | 83 ms
4,352 KB |
testcase_12 | AC | 81 ms
4,352 KB |
testcase_13 | AC | 2,609 ms
12,360 KB |
testcase_14 | AC | 1,838 ms
10,256 KB |
testcase_15 | AC | 1,639 ms
8,080 KB |
testcase_16 | AC | 2,031 ms
10,224 KB |
testcase_17 | AC | 1,444 ms
8,080 KB |
testcase_18 | AC | 1,203 ms
8,064 KB |
testcase_19 | AC | 2,293 ms
10,176 KB |
testcase_20 | AC | 1,445 ms
8,084 KB |
testcase_21 | AC | 2,076 ms
12,352 KB |
testcase_22 | TLE | - |
testcase_23 | AC | 2,192 ms
8,092 KB |
testcase_24 | AC | 2,183 ms
8,092 KB |
testcase_25 | AC | 2,186 ms
8,092 KB |
testcase_26 | AC | 2,201 ms
8,096 KB |
testcase_27 | AC | 2,206 ms
8,096 KB |
testcase_28 | AC | 2,199 ms
8,092 KB |
testcase_29 | AC | 2,192 ms
8,092 KB |
testcase_30 | AC | 2,188 ms
8,096 KB |
testcase_31 | AC | 2,188 ms
8,092 KB |
testcase_32 | AC | 2,186 ms
8,092 KB |
testcase_33 | TLE | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
ソースコード
package main import "fmt" type SegmentTree struct { n int dat [][2]int } func (this *SegmentTree) new(n int) { this.n = 1 for this.n < n { this.n *= 2 } this.dat = make([][2]int, 2*this.n-1) for _, d := range this.dat { d[0], d[1] = -1, -1 } } func (this *SegmentTree) update(k int, a int) { i := k k += this.n - 1 this.dat[k][0] = a this.dat[k][1] = i for k > 0 { k = (k - 1) / 2 this.dat[k] = Max(this.dat[k * 2 + 1], this.dat[k * 2 + 2]) } } func (this SegmentTree) max() int { return this.dat[0][1] + 1 } func (this SegmentTree) get(i int) int { return this.dat[i + this.n - 1][0] } func Max(a [2]int, b [2]int) [2]int{ if a[0] > b[0] { return a } else if a[0] < b[0] { return b } else if a[1] >= b[1] { return a } else { return b } } func main() { var N, M int fmt.Scan(&N, &M) var tree SegmentTree tree.new(M) for i := 0; i < M; i++ { var a int fmt.Scan(&a) tree.update(i, a) } var Q int fmt.Scan(&Q) q := make([][3]int, Q, Q) for i := 0; i < Q; i++ { fmt.Scan(&q[i][0], &q[i][1], &q[i][2]) } for _, a := range q { var ( t, x, y = a[0], a[1], a[2] ) if t == 1 { tree.update(x-1, tree.get(x-1) + y) } else if t == 2 { tree.update(x-1, tree.get(x-1) - y) } else { fmt.Println(tree.max()) } } }