結果

問題 No.825 賢いお買い物
ユーザー bluemeganebluemegane
提出日時 2019-05-11 07:16:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 3,309 ms
コンパイル使用メモリ 101,876 KB
実行使用メモリ 22,840 KB
最終ジャッジ日時 2023-09-14 18:05:46
合計ジャッジ時間 5,608 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,764 KB
testcase_01 AC 57 ms
20,688 KB
testcase_02 AC 56 ms
20,832 KB
testcase_03 AC 57 ms
20,724 KB
testcase_04 AC 57 ms
20,632 KB
testcase_05 AC 58 ms
20,724 KB
testcase_06 AC 57 ms
20,764 KB
testcase_07 AC 57 ms
20,624 KB
testcase_08 AC 58 ms
20,788 KB
testcase_09 AC 57 ms
20,724 KB
testcase_10 AC 58 ms
22,840 KB
testcase_11 AC 59 ms
20,740 KB
testcase_12 AC 58 ms
20,660 KB
testcase_13 AC 57 ms
20,768 KB
testcase_14 AC 58 ms
20,796 KB
testcase_15 AC 58 ms
18,720 KB
testcase_16 AC 58 ms
22,744 KB
testcase_17 AC 58 ms
22,808 KB
testcase_18 AC 59 ms
20,792 KB
testcase_19 AC 58 ms
20,736 KB
testcase_20 AC 58 ms
20,840 KB
testcase_21 AC 58 ms
20,696 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        getAns(a, b, c);
    }
    static void getAns(int a, int b, int c)
    {
        var ans = 1000;
        for (int i = 0; i <= a; i++)
            for (int j = 0; j <= b; j++)
            {
                var pay = i + 10 * j;
                if (pay >= 1)
                {
                    for (int k = 0; k <= pay - 1; k++)
                    {
                        var change = getChange(k);
                        var t = a + b - i - j + change;
                        if (t == c) ans = Min(ans, pay - k);
                    }
                }
            }
        if (ans == 1000) Console.WriteLine("Impossible");
        else Console.WriteLine(ans);
    }
    static int getChange(int a) => a - a / 10 * 9;
}

0