結果

問題 No.842 初詣
ユーザー kpinkcatkpinkcat
提出日時 2023-08-22 13:28:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 939 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 105,888 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 13:28:28
合計ジャッジ時間 2,086 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
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;
        if (i != 5) t = (g%base[i+1])/base[i];
        else t = g/500;
        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