結果
| 問題 |
No.1890 Many Sequences Sum Queries
|
| ユーザー |
ripity
|
| 提出日時 | 2022-04-04 15:18:05 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 487 bytes |
| コンパイル時間 | 96 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 27,808 KB |
| 最終ジャッジ日時 | 2024-11-25 06:49:02 |
| 合計ジャッジ時間 | 34,527 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 TLE * 10 |
ソースコード
N,Q = map(int,input().split())
a = list(map(int,input().split()))
c = []
for i in range(N):
c.append(a[i]*(a[i]+1)//2)
for _ in range(Q):
s = int(input())
sum_b = 0
ANS = 0
for i in range(N):
if sum_b+c[i] < s:
sum_b += c[i]
ANS += a[i]
elif sum_b < s:
for j in range(a[i]):
ANS += 1
sum_b += j+1
if sum_b >= s: break
if sum_b < s: print(-1)
else: print(ANS)
ripity