結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2016-10-29 01:04:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 961 bytes |
コンパイル時間 | 470 ms |
コンパイル使用メモリ | 64,208 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 08:27:49 |
合計ジャッジ時間 | 1,578 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <cstdio> #include <algorithm> #include <iostream> #include <vector> #include <string> #include <typeinfo> using namespace std; vector<int> a; int n; int sol(int x,int y, int z,int box[15]){ int tmp=0,res=0; int i,j,k; for(i=x;i<n;i++){ //cout<<"a"; for(j=i+1;j<n;j++){ //cout<<"b"; for(k=j+1;k<n;k++){ //cout<<"c"; if(a[i]!=0&&a[i]!=a[j]&&a[j]==a[k]&&box[i]!=1&&box[j]!=1&&box[k]!=1) { //cout<<"waro"<<endl; box[i]=box[j]=box[k]=1; tmp=sol(0,1,2,box)+a[i]*100+a[j]*11; box[i]=box[j]=box[k]=0; //res+=a[i]*100+a[j]*11; res=max(tmp,res); } } } } return res; } int main(void){ int i,l,r,k,t,j,tmp; int N; int res=0; string s; int box[15]; cin>>s; n=s.length(); a.resize(n); for(i=0;i<15;i++) box[i]=0; for(i=0;i<n;i++){ a[i]=s[i]-'0'; } tmp=sol(0,1,2,box); cout<<tmp<<endl; return 0; }