結果

問題 No.164 ちっちゃくないよ!!
ユーザー やまぞうやまぞう
提出日時 2015-03-18 00:51:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,081 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 82,008 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 08:31:10
合計ジャッジ時間 1,387 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdint>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

int N;
vector<string> V;
map<size_t, vector<string>> M;

void input(istream& in)
{
	in >> N;
	V.resize(N);
	for (int i = 0; i < N; i++) {
		in >> V[i];
	}
}

struct less_string
{
	bool operator()(const string& a, const string& b) const
	{
		return a < b;
	}
};

int64_t resolve()
{
	int base = 2;
	for (string& s : V) {
		for (char ch : s) {
			if (ch > base) {
				base = ch;
			}
		}
		size_t nz = s.find_first_not_of('0');
		M[s.length() - nz].push_back(s.substr(nz));
	}
	base = (base < 'A') ? (base - '0') : (base - 'A' + 10);
	base++;
	vector<string>& shortest_strings = M.begin()->second;
	string& smallest_value = *min_element(shortest_strings.begin(), shortest_strings.end(), less_string());
	int64_t value = 0;
	for (char ch : smallest_value) {
		value *= base;
		value += (ch < 'A') ? (ch - '0') : (ch - 'A' + 10);
	}
	return value;
}

int main()
{
	input(cin);
	cout << resolve() << endl;
	return 0;
}
0