結果

問題 No.825 賢いお買い物
ユーザー mmn15277198
提出日時 2020-07-07 20:25:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 80,240 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 19:05:25
合計ジャッジ時間 2,179 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
#include <map>
using namespace std;

int main(){
	int a,b,c;
	int ans=101010101;
	cin >> a >> b >> c;
	for(int k=1;k<=a+10*b;k++){
		for(int j=0;j<=b;j++){
			if(10*j-k>=10)break;
			for(int i=0;i<=a;i++){
				if(k<=i+10*j){
					int OT=i+10*j-k;
					if(c==a+b-i-j+OT || c==a+b-i-j+(OT/10)+(OT%10)){
						ans=min(ans,k);
					}
				}
			}
		}
	}
	if(ans==101010101){
		cout << "Impossible" << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}
0