結果
| 問題 |
No.2681 ゲームセンターの両替
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-20 21:17:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 593 bytes |
| コンパイル時間 | 2,094 ms |
| コンパイル使用メモリ | 195,380 KB |
| 最終ジャッジ日時 | 2025-02-20 08:34:20 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int C,Y; cin >> C >> Y;
if(C*100 > Y){cout << "can't exchange" << endl; return 0;}
int N = 10;
vector<int> money = {1,5,10,50,100,500,1000,2000,5000,10000};
reverse(money.begin(),money.end());
vector<int> have(N);
for(int i=0; i<N; i++) have.at(i) = Y/money.at(i),Y %= money.at(i);
if(have.at(5) >= C){cout << "no exchange" << endl; return 0;}
int left = C-have.at(5);
left += (5-left%5)%5;
cout << have.at(5)+left << endl;
}