結果

問題 No.842 初詣
コンテスト
ユーザー subsn
提出日時 2023-06-16 14:41:41
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 775 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 164 ms
コンパイル使用メモリ 38,464 KB
最終ジャッジ日時 2026-02-22 10:51:37
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
int main()
{
    int c_500, c_100, c_50, c_10, c_5, c_1,p;
    scanf("%d%d%d%d%d%d%d",&c_500,&c_100,&c_50,&c_10,&c_5,&c_1,&p);
    for (;;) {
        if (c_500 == 0 || !p || p < 500) break;
        c_500--;
        p-=500;
    }
    for (;;) {
        if (c_100 == 0 || !p || p < 100) break;
        c_100--;
        p -= 100;
    }
    for (;;) {
        if (c_50 == 0 || !p || p < 50) break;
        c_50--;
        p -= 50;
    }
    for (;;) {
        if (c_10 == 0 || !p || p < 10) break;
        c_10--;
        p -= 10;
    }
    for (;;) {
        if (c_5 == 0 || !p || p < 5) break;
        c_5--;
        p -= 5;
    }
    for (;;) {
        if (c_1 == 0 || !p || p < 1) break;
        c_1--;
        p -= 1;
    }
    p?puts("NO"):puts("YES");
}
0