結果

問題 No.437 cwwゲーム
ユーザー ぴろず
提出日時 2016-10-28 22:43:29
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,154 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 77,632 KB
実行使用メモリ 41,508 KB
最終ジャッジ日時 2024-11-24 05:51:45
合計ジャッジ時間 8,787 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 14 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

package no437;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int[] x = new int[n];
		for(int i=0;i<n;i++) {
			x[i] = s.charAt(i) - '0';
		}
		int m = (n + 2) / 3;
		int[] p = new int[n];
		int[] a = new int[m];
		int max = 0;
		do {
			if (p[0] >= 1) break;
			int score = 0;
			Arrays.fill(a, 0);
			for(int i=0;i<n;i++) {
				int j = p[i];
				int c = x[i];
				if (a[j] == 0 && c == 0) {
					continue;
				}
				if (a[j] >= 100) {
					continue;
				}
				a[j] = a[j] * 10 + c;
			}
			for(int i=0;i<m;i++) {
				if (a[i] < 100 || a[i] % 111 == 0 || a[i] % 100 % 11 != 0) {
					continue;
				}
				score += a[i];
			}
//			if (max < score) {
//				System.out.println(score + " " + Arrays.toString(a));
//			}
			max = Math.max(max, score);
		} while (nextSequence(p, m));
		System.out.println(max);
	}
	public static boolean nextSequence(int[] s, int k) {
		int n = s.length;
		for(int i=0;i<n;i++) {
			s[i]++;
			if (s[i] < k) {
				return true;
			}
			s[i] = 0;
		}
		return false;
	}
}
0