結果

問題 No.437 cwwゲーム
ユーザー albicilla
提出日時 2016-11-03 14:07:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 961 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 159,588 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 02:25:17
合計ジャッジ時間 2,286 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

string s;
int ans;
int a[15];
int main(){
  cin>>s;
  for(int i=0;i<11;i++)a[i]=0;

  for(int i=s.size()-1;i>=0;i--){
    int p=(s[i]-'0');
    a[p]++;
      if(a[p]>=2){
      //  cout<<"i="<<i<<" "<<a[p]<<endl;
      //  cout<<"i="<<i<<endl;
        a[p]=0;
        int mx=0,memo=-1;
        if(i==0)break;
        int a_memo=p;
        for(int j=i;j>=0;j--){
          int temp=mx;
          p=(s[j]-'0');
        //  cout<<p<<endl;
          if(p!=a_memo){
            mx=max(p,mx);
            if(mx!=temp){
              memo=j;
            }
          }
        }
        if(memo!=-1){
          int t=(s[memo]-'0');
        //  cout<<"memo="<<memo<<endl;
          //cout<<"t="<<t<<" i="<<i<<" s[i]"<<s[i]<<endl;

        //  cout<<"s="<<s<<endl;

          ans+=t*100+(s[i]-'0')*11;
          //cout<<ans<<endl;
          s.erase(s.begin()+memo);
          i--;
        }
      }
  }
  cout<<ans<<endl;
}
0