結果

問題 No.1453 手助け
ユーザー Yuu EguciYuu Eguci
提出日時 2023-04-14 18:22:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,734 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-18 16:12:02
合計ジャッジ時間 1,802 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 25 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 28 ms
10,752 KB
testcase_07 AC 29 ms
10,752 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 27 ms
10,624 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 30 ms
10,752 KB
testcase_12 AC 30 ms
10,752 KB
testcase_13 AC 26 ms
10,752 KB
testcase_14 AC 25 ms
10,624 KB
testcase_15 AC 27 ms
10,624 KB
testcase_16 AC 28 ms
10,752 KB
testcase_17 AC 25 ms
10,752 KB
testcase_18 AC 28 ms
10,752 KB
testcase_19 AC 27 ms
10,752 KB
testcase_20 AC 31 ms
10,752 KB
testcase_21 AC 28 ms
10,752 KB
testcase_22 AC 26 ms
10,752 KB
testcase_23 AC 31 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calculate_total_price(A: int, B: int, C: int, D: int, E: int) -> int:
    """
    パーティを開く予定なので、手土産に飴玉を買おうと思っています。
    必要なぶんの飴玉を買うための合計金額を算出します。

    Args:
        A: int 1~100, 1人あたりに配る飴玉の数
        B: int C~100, 招待する人数
        C: int 1~B, 来てくれない人数
        D: int 1~1000, 最初の飴玉の値段
        E: int 1~1000, 割引が適用される個数

    Returns:
        int: 必要な飴玉の総額

    Raises:
        ValueError: 引数が要求される条件を満たしていない場合
    """
    if not 1 <= A <= 100:
        raise ValueError("A must be between 1 and 100")
    if not C <= B <= 100:
        raise ValueError("B must be between C and 100")
    if not 1 <= C <= B:
        raise ValueError("C must be between 1 and B")
    if not 1 <= D <= 1000:
        raise ValueError("D must be between 1 and 1000")
    if not 1 <= E <= 1000:
        raise ValueError("E must be between 1 and 1000")

    # 1人あたりに必要な飴玉の数
    num_candies_per_person = A
    # 実際に来てくれた人数
    actual_guests = B - C
    # 必要な飴玉の総数
    total_candies = num_candies_per_person * actual_guests
    # 最初の飴玉の価格
    current_price = D
    # 必要な飴玉の総額
    total_price = 0

    for i in range(1, total_candies + 1):
        # i個目の飴玉の価格を計算する
        if i % 10 == 0 and E <= current_price:
            current_price -= E
        total_price += current_price

    return total_price


A, B, C, D, E = map(int, input().split())
print(calculate_total_price(A, B, C, D, E))
0