結果

問題 No.842 初詣
ユーザー kpinkcatkpinkcat
提出日時 2023-08-22 13:15:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 1,127 ms
コンパイル使用メモリ 105,120 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-22 13:15:34
合計ジャッジ時間 2,391 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
using namespace std;


int main()
{
    int g;
    vector<int> base = {1, 5, 10, 50, 100, 500}, num(6);
    for (int i = 0; i < 6; i++) cin >> num[5-i];
    cin >> g;
    for (int i = 0; i < 6; i++){
        int t = (g%base[i+1])/base[i];
        if (t <= num[i]){
            g -= t*base[i];
            num[i] -= t;
        } else {
            cout << "NO" << endl;
            return 0;
        }
        if (i == 0) num[1] += num[0]/5;
        if (i == 1) num[2] += num[1]*5/10;
        if (i == 2) num[3] += num[2]/5;
        if (i == 3) num[4] += num[3]*5/10;
        if (i == 4) num[5] += num[4]/5;
        if (g == 0){
            cout << "YES" << endl;
            return 0;
        } 
    }
    cout << ((g == 0) ? "YES" : "NO") << endl; 
}
0