結果

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

ソースコード

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<<a[8]<<endl;
      //  cout<<"i="<<i<<endl;
        a[p]=0;
        int mx=0,memo=-1;
        if(i==0)break;
        for(int j=i-1;j>=0;j--){
          int temp=mx;
          p=(s[j]-'0');
          mx=max(p,mx);
          if(mx!=temp||mx==p){
            memo=j;
          }
        }
        if(memo!=-1){
          int t=(s[memo]-'0');
        //  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