結果

問題 No.825 賢いお買い物
コンテスト
ユーザー MarcusAureliusAntoninus
提出日時 2019-05-03 21:57:55
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 832µs
コード長 521 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,284 ms
コンパイル使用メモリ 209,180 KB
実行使用メモリ 9,800 KB
最終ジャッジ日時 2026-10-13 10:54:17
合計ジャッジ時間 2,876 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

int solve();

int main()
{
	int ans{solve()};
	if (ans < 0) puts("Impossible");
	else printf("%d\n", ans);

	return 0;
}

int solve()
{
	int A, B, C;
	scanf("%d%d%d", &A, &B, &C);
	
	for (int cost{1}; cost <= A + 10 * B; cost++)
	{
		for (int a_i{}; a_i <= A; a_i++)
		{
			for (int b_i{}; b_i <= B; b_i++)
			{
				if (a_i + 10 * b_i < cost) continue;
				int change{a_i + 10 * b_i - cost};
				if (A - a_i + B - b_i + change / 10 + change % 10 == C)
					return cost;
			}
		}
	}
	return -1;
}
0