結果

問題 No.825 賢いお買い物
ユーザー yansi819yansi819
提出日時 2024-03-28 17:30:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 4,603 ms
コンパイル使用メモリ 262,640 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-28 17:30:10
合計ジャッジ時間 5,662 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

int main() {
  int a, b, c; cin >> a >> b >> c;
  int ans = 1e9;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      if (i == 0 && j == 0) continue;
      for (int k = 1; k <= a + 10 * b; k++) {
        int x = i + 10 * j - k;
        if (x < 0) continue;
        int n = x % 10;
        int m = x / 10;
        if (a - i + b - j + n + m == c) {
          //cout << i << ' ' << j << ' ' << k << ' ' << x << ' ' << n << ' ' << m << ' ' << i + 10 * j << endl;
          ans = min(ans, k);
        }
      }
    }
  }
  if (ans == 1e9) cout << "Impossible" << endl;
  else cout << ans << endl;
  return 0;
}
0