結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2016-10-28 22:44:03 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,156 bytes |
| コンパイル時間 | 1,911 ms |
| コンパイル使用メモリ | 77,484 KB |
| 実行使用メモリ | 108,812 KB |
| 最終ジャッジ日時 | 2024-11-24 05:52:49 |
| 合計ジャッジ時間 | 15,883 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 TLE * 1 |
ソースコード
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[n-1] >= 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;
}
}
ぴろず