提出 #74570023


ソースコード 拡げる

##########################################################
# solution.py
##########################################################
# n, q = map(int, input().split())
# a = list(map(int, input().split()))

# acc = [0] * (n + [[0]])
# for i in range(n + [[1]]):
#     acc[i + 1] = acc[i] + a[i + [[2]]]

# for j in range(q):
#     l, r = map(int, input().split())
#     print(acc[r + [[3]]] - acc[l + [[4]]])


##########################################################
# in01.txt
##########################################################
# 10 5
# 8 6 9 1 2 1 10 100 1000 10000
# 2 3
# 1 4
# 3 9
# 6 8
# 1 10


##########################################################
# out01.txt
##########################################################
# 15
# 24
# 1123
# 111
# 11137


##########################################################
# gacha.py
##########################################################
# import itertools
# import subprocess
# import re
# import os
# import glob

# # --- 設定 ---
# TARGET_PY = "solution.py"
# TEMP_PY = "_exec_temp.py"
# MAX_TEST_CASES = 1  # 使用するテストケースの最大数 (0を指定すると全件)

# def get_test_cases(limit=0):
#     """in*.txt とそれに対応する out*.txt のペアを取得する"""
#     input_files = sorted(glob.glob("in*.txt"))
        
#     # 制限がある場合はスライス
#     if limit > 0:
#         input_files = input_files[:limit]
        
#     cases = []
#     for in_file in input_files:
#         # 対応する出力ファイルを探す (in01.txt -> out01.txt, in_sample.txt -> out_sample.txt)
#         out_file = in_file.replace("in", "out")
#         if os.path.exists(out_file):
#             with open(in_file, "r", encoding="utf-8") as f_in:
#                 stdin_data = f_in.read()
#             with open(out_file, "r", encoding="utf-8") as f_out:
#                 # 比較のために前後の空白を削除
#                 expected_stdout = f_out.read().strip()
#             cases.append((in_file, stdin_data, expected_stdout))
            
#     return cases

# def run_with_input(code, input_str):
#     with open(TEMP_PY, "w", encoding="utf-8") as f:
#         f.write(code)
    
#     try:
#         res = subprocess.run(
#             ["python", TEMP_PY],
#             input=input_str,
#             capture_output=True,
#             text=True,
#             timeout=2
#         )
#         if res.returncode != 0:
#             return None
#         return res.stdout.strip()
#     except Exception:
#         return None

# def main():
#     if not os.path.exists(TARGET_PY):
#         print(f"Error: {TARGET_PY} not found.")
#         return

#     # MAX_TEST_CASES に基づいて取得
#     test_cases = get_test_cases(limit=MAX_TEST_CASES)
    
#     if not test_cases:
#         print("No matching test cases found.")
#         return
    
#     print(f"Loaded {len(test_cases)} test cases (Limit: {MAX_TEST_CASES if MAX_TEST_CASES > 0 else 'All'}).")
#     for name, _, _ in test_cases:
#         print(f"  - Using: {name}")

#     with open(TARGET_PY, "r", encoding="utf-8") as f:
#         template = f.read()

#     marker_ids = sorted(list(set(re.findall(r"\[\[(\d+)\]\]", template))))
#     num_vars = len(marker_ids)
    
#     if num_vars == 0:
#         print("\n[!] No markers [[n]] found. Please mark offsets in solution.py.")
#         return

#     print(f"\nStarting Gacha: 3^{num_vars} = {3**num_vars} patterns...")

#     found_count = 0
#     for pattern in itertools.product([-1, 0, 1], repeat=num_vars):
#         current_code = template
#         for i, val in enumerate(pattern):
#             current_code = current_code.replace(f"[[{i}]]", str(val))
        
#         all_pass = True
#         for name, stdin_data, expected in test_cases:
#             actual = run_with_input(current_code, stdin_data)
#             if actual != expected:
#                 all_pass = False
#                 break
        
#         if all_pass:
#             found_count += 1
#             print(f"\n✅ [SUCCESS] Solution #{found_count} | Pattern: {pattern}")
#             print("-" * 40)
#             print(current_code)
#             print("-" * 40)

#     if found_count == 0:
#         print("\n❌ No combinations satisfied the selected test cases.")
    
#     if os.path.exists(TEMP_PY):
#         os.remove(TEMP_PY)

# if __name__ == "__main__":
#     main()


##########################################################
# gacha.py からの出力
##########################################################
# Loaded 1 test cases (Limit: 1).
#   - Using: in01.txt

# Starting Gacha: 3^5 = 243 patterns...

# ✅ [SUCCESS] Solution #1 | Pattern: (1, 0, 0, 0, -1)
# ----------------------------------------
n, q = map(int, input().split())
a = list(map(int, input().split()))

acc = [0] * (n + 1)
for i in range(n + 0):
    acc[i + 1] = acc[i] + a[i + 0]

for j in range(q):
    l, r = map(int, input().split())
    print(acc[r + 0] - acc[l + -1])

# ----------------------------------------

提出情報

提出日時
問題 038 - How Many Guests?
ユーザ ecottea
言語 Python (CPython 3.13.7)
得点 1000
コード長 5217 Byte
結果 AC
実行時間 222 ms
メモリ 19148 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 1000 / 1000
結果
AC × 1
AC × 10
セット名 テストケース
Sample sample_01.txt
All sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 10 ms 9296 KiB
test_01.txt AC 10 ms 9212 KiB
test_02.txt AC 73 ms 13544 KiB
test_03.txt AC 61 ms 14908 KiB
test_04.txt AC 163 ms 14620 KiB
test_05.txt AC 37 ms 10064 KiB
test_06.txt AC 219 ms 19084 KiB
test_07.txt AC 222 ms 19080 KiB
test_08.txt AC 217 ms 19120 KiB
test_09.txt AC 214 ms 19148 KiB