結果
| 問題 |
No.1015 おつりは要らないです
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-02 19:13:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 507 bytes |
| コンパイル時間 | 2,449 ms |
| コンパイル使用メモリ | 196,028 KB |
| 最終ジャッジ日時 | 2025-01-10 20:38:02 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | int n,m[3]; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:12:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | rep(i,3) scanf("%d",&m[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:16:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | int a; scanf("%d",&a);
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
const int p[3]={1000,5000,10000};
int n,m[3]; scanf("%d",&n);
rep(i,3) scanf("%d",&m[i]);
priority_queue<int> Q;
rep(i,n){
int a; scanf("%d",&a);
Q.emplace(a+1);
}
for(int i=2;i>=0;i--){
while(m[i]>0 && !Q.empty()){
int a=Q.top(); Q.pop();
int k=min(a/p[i],m[i]);
if(k==0) k++;
a-=p[i]*k;
if(a>0) Q.emplace(a);
m[i]-=k;
}
}
puts(Q.empty()?"Yes":"No");
return 0;
}