結果
| 問題 | No.1890 Many Sequences Sum Queries |
| ユーザー |
ID 21712
|
| 提出日時 | 2025-06-09 03:00:46 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 527 bytes |
| コンパイル時間 | 11,260 ms |
| コンパイル使用メモリ | 236,332 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2025-06-09 03:01:07 |
| 合計ジャッジ時間 | 19,144 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 WA * 17 |
ソースコード
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