結果
問題 | No.437 cwwゲーム |
ユーザー |
|
提出日時 | 2018-05-30 23:08:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,021 bytes |
コンパイル時間 | 573 ms |
コンパイル使用メモリ | 68,064 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 08:25:46 |
合計ジャッジ時間 | 1,745 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 28 WA * 13 |
ソースコード
#include <iostream> #include <string> #include <string.h> using namespace std; int getValue(string &S,int x,int y,int z) { string S1; S1=S[x]; S1+=S[y]; S1+=S[z]; S.erase(z,1); S.erase(y,1); S.erase(x,1); return atol(S1.c_str()); } bool Check(string S,int x,int y,int z) { if (S[y]==S[z]){ return true; }else{ return false; } } int deal(string &S) { int i,j,k; int sLen=S.length(); int value=0; for (i=0;i<sLen-2;i++){ for (j=i+1;j<sLen-1;j++){ for (k=j+1;k<sLen;k++){ if (S[i]!=S[j] && S[j]==S[k]){ value=+getValue(S,i,j,k); return value; } } } } return 0; } int main(int argc, char* argv[]) { string N,N1; int maxScore=0; cin>>N; int nLen=N.length(); if (nLen<=2){ cout<<0<<endl; return 0; } int i; for (i=0;i<nLen-2;i++){ string n=N.c_str()+i; int score=0; while (n.length()>0){ int value=deal(n); if (value>0){ score+=value; }else{ break; } } if (maxScore<score){ maxScore=score; } } cout<<maxScore<<endl; return 0; }