結果
問題 | No.825 賢いお買い物 |
ユーザー | betweens |
提出日時 | 2019-05-20 23:46:25 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,638 bytes |
コンパイル時間 | 943 ms |
コンパイル使用メモリ | 99,968 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 06:44:34 |
合計ジャッジ時間 | 1,614 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | WA | - |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | WA | - |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
ソースコード
#include <iostream> #include <cmath> #include <vector> #include <string> #include <map> #include <algorithm> #include <numeric> #include <fstream> #include <iomanip> typedef long double ld; typedef long long ll; const ll INF = (ll)1e18 + 1; const ll MOD = 1e9 + 7; // Split namespace util { std::vector< std::string > split(std::string s, char delimiter) { std::vector< std::string > vs; std::string sub; for (auto c : s) { if (c == delimiter) vs.push_back(sub), sub.clear(); else sub += c; } vs.push_back(sub); return vs; } } // namespace util // Minimum, Maximum template<class T> T minimum(T head, T tail) { return std::min(head, tail); } template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); } template<class T> T maximum(T head, T tail) { return std::max(head, tail); } template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); } // Output template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p) { return os << p.first << " " << p.second; } template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v) { for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; } return os; } template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp) { ll i = 0; for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;} return os; } void print(){ std::cout << std::endl; } template<typename H> void print(H head) { std::cout << head << std::endl; } template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); ll A, B, C; std::cin >> A >> B >> C; if (A + B <= C) { print("Impossible"); return 0; } std::vector<ll> coin(2); coin[0] = 1; coin[1] = 10; ll a = A; ll b = B; ll c = C; ll ans1 = INF; if (A >= 11 && A + B - C >= 10) { a -= 11; b += 1; ans1 = 1; std::vector<ll> vnum(2); vnum[0] = b; vnum[1] = a; for (ll i = 0; i < 2; i++) { while (vnum[0] + vnum[1] > c && vnum[i] > 0) { ans1 += coin[i]; vnum[i]--; } } } a = A; b = B; c = C; ll ans2 = 0LL; std::vector<ll> vnum(2); vnum[0] = a; vnum[1] = b; for (ll i = 0; i < 2; i++) { while (vnum[0] + vnum[1] > c && vnum[i] > 0) { ans2 += coin[i]; vnum[i]--; } } print(std::min(ans1, ans2)); return 0; }