結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2016-10-28 22:29:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 670 bytes |
コンパイル時間 | 1,383 ms |
コンパイル使用メモリ | 168,504 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 08:20:33 |
合計ジャッジ時間 | 2,495 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include<bits/stdc++.h> using namespace std; map<string,int> mp; int solve(string s){ if(mp.count(s))return mp[s]; int res=0; for(int i=0;i<(int)s.size();i++){ if(s[i]=='0')continue; for(int j=i+1;j<(int)s.size();j++){ if(s[j]==s[i])continue; for(int k=j+1;k<(int)s.size();k++){ if(s[j]!=s[k])continue; string tmp=""; for(int l=0;l<(int)s.size();l++) if(l!=i&&l!=j&&l!=k) tmp+=s[l]; int num=(s[i]-'0')*100+(s[j]-'0')*10+(s[k]-'0'); res=max(res,num+solve(tmp)); } } } return mp[s]=res; } int main(){ string N; cin>>N; cout<<solve(N)<<endl; return 0; }