結果
| 問題 | No.1890 Many Sequences Sum Queries |
| ユーザー |
ID 21712
|
| 提出日時 | 2025-06-09 03:03:19 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 1,274 ms / 2,000 ms |
| コード長 | 528 bytes |
| コンパイル時間 | 13,882 ms |
| コンパイル使用メモリ | 254,932 KB |
| 実行使用メモリ | 8,096 KB |
| 最終ジャッジ日時 | 2025-06-09 03:03:43 |
| 合計ジャッジ時間 | 21,191 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
package main
import . "fmt"
import . "sort"
func main() {
var n,q int
Scan(&n,&q)
a := make([]int, n)
t := make([]int, n+1)
x := make([]int, n+1)
for i := range a {
Scan(&a[i])
t[i+1] = t[i] + a[i]*(a[i]+1)/2
x[i+1] = x[i] + a[i]
}
for ;q>0;q-- {
var s int
Scan(&s)
p := SearchInts(t, s)
if p == len(t) {
Println(-1)
continue
}
if s == t[p] {
Println(x[p])
continue
}
e := Search(a[p-1], func(k int) bool {
w := t[p-1]+(k+1)*(k+2)/2
return w >= s
})
Println(x[p-1]+e+1)
}
}
ID 21712