結果
| 問題 |
No.1099 Range Square Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-05 18:39:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 855 bytes |
| コンパイル時間 | 371 ms |
| コンパイル使用メモリ | 82,160 KB |
| 実行使用メモリ | 73,856 KB |
| 最終ジャッジ日時 | 2024-08-05 18:39:35 |
| 合計ジャッジ時間 | 9,118 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 |
| other | -- * 30 |
ソースコード
def main():
import sys
input = sys.stdin.read
data = input().strip().split()
N = int(data[0])
Q = int(data[1])
array = list(map(int, data[2:N+2]))
queries = data[N+2:]
add_value = 0
result = []
query_index = 0
while query_index < len(queries):
query_type = int(queries[query_index])
if query_type == 1:
# クエリ1: 全ての要素にXを加える
X = int(queries[query_index + 1])
add_value += X
query_index += 2
elif query_type == 2:
# クエリ2: A_iの値を出力する
i = int(queries[query_index + 1]) - 1
result.append(array[i] + add_value)
query_index += 2
# 結果を出力
print("\n".join(map(str, result)))
if __name__ == "__main__":
main()