結果

問題 No.176 2種類の切手
ユーザー masa
提出日時 2015-04-02 23:34:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 65,660 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-08 01:27:43
合計ジャッジ時間 5,007 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 6 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

int main() {
	int a, b, t;

	cin >> a >> b >> t;

	int big = max(a, b);
	int small = min(a, b);

	if (small == 1) {
		return t;
	}

	int pay_big, pay_small;
	int left;
	int ans = 2e9;
	for (int i = ceil(1.0 * t) / big; i >= 0; i--) {
		pay_big = i * big;
		left = t - pay_big;
		pay_small = ceil(1.0 * left / small) * small;
		ans = min(ans, pay_big + pay_small);
	}

	cout << ans << endl;
	return 0;
}
0