結果
問題 |
No.2681 ゲームセンターの両替
|
ユーザー |
![]() |
提出日時 | 2024-05-26 22:32:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 769 ms |
コンパイル使用メモリ | 87,480 KB |
最終ジャッジ日時 | 2025-02-21 16:50:43 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> #include <cassert> #include <vector> #include <map> #include <algorithm> using namespace std; int main() { vector<int> cands = {1,5,10,50,100,500}; reverse(cands.begin(), cands.end()); map<int, int> mp; int C, Y; cin >> C >> Y; for (int cand: cands) { int cnt = Y / cand; mp[cand] = cnt; Y -= cand * cnt; } if (mp[100] >= C) { cout << "no exchange" << endl; } else if (mp[500] * 5 + mp[100] < C) { cout << "can't exchange" << endl; } else { int need = C - mp[100]; int t = ((need + 4) / 5); int ans = mp[100] + t * 5; cout << ans << endl; } return 0; }