結果

問題 No.825 賢いお買い物
ユーザー MarcusAureliusAntoninus
提出日時 2019-05-03 21:57:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 192,872 KB
最終ジャッジ日時 2025-01-07 03:23:46
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int solve()’:
main.cpp:17:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         scanf("%d%d%d", &A, &B, &C);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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