結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2016-10-28 22:31:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,231 bytes |
コンパイル時間 | 602 ms |
コンパイル使用メモリ | 80,164 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 05:47:24 |
合計ジャッジ時間 | 1,777 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 10 |
ソースコード
#include <algorithm>#include <cstdio>#include <cstdlib>#include <cctype>#include <cmath>#include <iostream>#include <queue>#include <list>#include <stack>#include <map>#include <numeric>#include <set>#include <sstream>#include <string>#include <vector>using namespace std;#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)#define rep(i,n) REP(i,0,n)#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)#define ALLOF(c) (c).begin(), (c).end()typedef long long ll;int main(){ios::sync_with_stdio(false);string N;cin >> N;ll ret = 0;while(true){ll mx = -1;int mxi, mxj, mxk;rep(i,N.length()){REP(j,i+1,N.length()){REP(k,j+1,N.length()){if(N[i]=='-' || N[j]=='-' || N[k]=='-' || N[i]=='0') continue;ll x = (int)(N[i]-'0')*100 + (int)(N[j]-'0')*10 + (int)(N[k]-'0');if(N[i] != N[j] && N[j] == N[k]){if(mx < x){mxi=i;mxj=j;mxk=k;mx = max(mx, x);}}}}}if(mx == -1) break;ret += mx;N[mxi] = '-';N[mxj] = '-';N[mxk] = '-';}cout << ret << endl;return 0;}