結果
| 問題 | No.842 初詣 | 
| コンテスト | |
| ユーザー |  MarcusAureliusAntoninus | 
| 提出日時 | 2019-06-28 21:32:09 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 316 bytes | 
| コンパイル時間 | 1,741 ms | 
| コンパイル使用メモリ | 191,516 KB | 
| 最終ジャッジ日時 | 2025-01-07 05:24:21 | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 21 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         for (int i{}; i < 6; i++) scanf("%d", num + i);
      |                                   ~~~~~^~~~~~~~~~~~~~~
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d", &G);
      |         ~~~~~^~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
int main()
{
	int num[6]{}, price[6]{500, 100, 50, 10, 5, 1};
	for (int i{}; i < 6; i++) scanf("%d", num + i);
	int G;
	scanf("%d", &G);
	for (int i{}; i < 6; i++)
		for (int j{num[i]}; j > 0 && G >= price[i]; j--)
			G -= price[i];
	if (G == 0) puts("YES");
	else puts("NO");
	return 0;
}
            
            
            
        