結果

問題 No.164 ちっちゃくないよ!!
ユーザー CELICACELICA
提出日時 2020-10-01 21:10:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 3,060 ms
コンパイル使用メモリ 169,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 09:49:27
合計ジャッジ時間 2,486 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;

template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
		a = b;
	return a > b;
}

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

	int n;
	cin >> n;

	ll res{ (ll)1e20 };
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		string sw(s);
		sort(sw.rbegin(), sw.rend());
		char m = sw[0];
		char r = (m <= '9' ? '0' : 'A' - 10);
		int mm = m - r + 1;

		ll x = 1, sum{ 0 };
		for (int d = (int)s.size() - 1; d >= 0; --d)
		{
			if (s[d] <= '9')
				sum += (s[d] - '0') * x;
			else
				sum += (s[d] - 'A' + 10) * x;
			x *= mm;
		}
		chmin(res, sum);
	}

    cout << res << "\n";

	return 0;
}
0