結果

問題 No.437 cwwゲーム
ユーザー くれちー
提出日時 2016-10-29 00:15:22
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 777 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 06:48:31
合計ジャッジ時間 1,789 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 11 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int iscww(int *a) {
	if (a[0] > 0 && a[1] >= 0 && a[2] >= 0) {
		if (a[0] < a[1] && a[1] == a[2]) return 1;
		else return 0;
	}
	else return 0;
}

int main() {
	char n;
	int cnt[10] = {}, score = 0, tmp[3], sum, i;

	while ((n = getchar()) != '\n') {
		cnt[n - '0']++;
	}

	while (1) {
		tmp[0] = tmp[1] = tmp[2] = -1;
		for (i = 9; i >= 0; i--) {
			if (cnt[i] >= 2) {
				tmp[1] = tmp[2] = i;
				cnt[i] -= 2;
				break;
			}
		}
		for (i = tmp[1] - 1; i >= 0; i--) {
			if (cnt[i] > 0) {
				tmp[0] = i;
				cnt[i]--;
				break;
			}
		}

		if (!iscww(tmp)) break;
		else score += tmp[0] * 100 + tmp[1] * 10 + tmp[2];

		sum = 0;
		for (i = 0; i < 10; i++) sum += cnt[i];
		if (sum < 3) break;
	}

	printf("%d\n", score);
	return 0;
}
0