結果

問題 No.825 賢いお買い物
ユーザー sonotarou
提出日時 2021-03-01 20:37:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 3,793 ms
コンパイル使用メモリ 228,884 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-03 00:57:18
合計ジャッジ時間 4,819 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

int a,b,c;

string solve(){
    for(int p=1;p<=a+10*b;p++){
        rep(i,a+1)rep(j,b+1){
            if(i+j*10>=p){
                int o=i+j*10-p;
                if(a-i+b-j+o/10+o%10 == c) return to_string(p);
            }
        }
    }
    return "Impossible";
}

int main () {
    cin.tie(0); ios::sync_with_stdio(false); 

    cin >> a >> b >> c;
    cout << solve() << '\n';
}
0