結果

問題 No.2681 ゲームセンターの両替
ユーザー bluemegane
提出日時 2024-04-09 07:16:05
言語 C#
(.NET 8.0.404)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 836 bytes
コンパイル時間 8,237 ms
コンパイル使用メモリ 167,468 KB
実行使用メモリ 183,852 KB
最終ジャッジ日時 2024-10-05 04:17:06
合計ジャッジ時間 8,414 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (111 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var c = int.Parse(line[0]);
        var y = int.Parse(line[1]);
        getAns(c, y);
    }
    static int[] getArray(int y, int[] t)
    {
        var a = new int[6];
        for (int i = 0; i < 6; i++)
        {
            a[i] = y / t[i];
            y -= a[i] * t[i];
        }
        Array.Reverse(a);
        return a;
    }
    static void getAns(int c, int y)
    {
        var t = new int[] { 10000, 5000, 2000, 1000, 500, 100 };
        if (c * 100 > y) { Console.WriteLine("can't exchange"); return; }
        var a = getArray(y, t);
        if (a[0] + a[1] >= c) { Console.WriteLine("no exchange"); return; }
        c -= a[0];
        Console.WriteLine((c + 4) / 5 * 5 + a[0]);
    }
}
0