結果
問題 |
No.164 ちっちゃくないよ!!
|
ユーザー |
|
提出日時 | 2015-03-18 00:51:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,081 bytes |
コンパイル時間 | 725 ms |
コンパイル使用メモリ | 80,936 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-28 23:07:42 |
合計ジャッジ時間 | 1,274 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 6 |
ソースコード
#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; }