結果

問題 No.45 回転寿司
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-16 22:37:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 490 ms / 5,000 ms
コード長 989 bytes
コンパイル時間 3,595 ms
コンパイル使用メモリ 74,004 KB
実行使用メモリ 180,244 KB
最終ジャッジ日時 2023-08-27 13:58:16
合計ジャッジ時間 12,477 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
78,372 KB
testcase_01 AC 310 ms
89,592 KB
testcase_02 AC 390 ms
127,448 KB
testcase_03 AC 424 ms
134,332 KB
testcase_04 AC 306 ms
93,460 KB
testcase_05 AC 151 ms
58,136 KB
testcase_06 AC 303 ms
86,912 KB
testcase_07 AC 445 ms
127,168 KB
testcase_08 AC 189 ms
65,552 KB
testcase_09 AC 416 ms
131,812 KB
testcase_10 AC 274 ms
79,120 KB
testcase_11 AC 171 ms
61,088 KB
testcase_12 AC 403 ms
125,384 KB
testcase_13 AC 151 ms
56,144 KB
testcase_14 AC 149 ms
56,232 KB
testcase_15 AC 246 ms
78,620 KB
testcase_16 AC 188 ms
65,084 KB
testcase_17 AC 235 ms
78,788 KB
testcase_18 AC 196 ms
68,168 KB
testcase_19 AC 346 ms
111,996 KB
testcase_20 AC 146 ms
55,948 KB
testcase_21 AC 150 ms
56,236 KB
testcase_22 AC 126 ms
55,956 KB
testcase_23 AC 127 ms
55,564 KB
testcase_24 AC 126 ms
55,852 KB
testcase_25 AC 128 ms
55,848 KB
testcase_26 AC 231 ms
78,836 KB
testcase_27 AC 350 ms
110,300 KB
testcase_28 AC 296 ms
87,640 KB
testcase_29 AC 339 ms
110,624 KB
testcase_30 AC 341 ms
110,468 KB
testcase_31 AC 129 ms
55,548 KB
testcase_32 AC 126 ms
55,996 KB
testcase_33 AC 490 ms
180,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int n = koko.nextInt();
        int[] v = new int[n];
        int total=0;
        for(int i=0; i<n; i++){
            v[i]=koko.nextInt();
            total=total+v[i];
        }
        boolean[][][] sushi = new boolean[n+1][2][total+1];
        sushi[0][0][0]=true;
        for(int i=0; i<n; i++){
            for(int j=0; j<total+1; j++){
                if(sushi[i][0][j]){
                    sushi[i+1][0][j]=true;
                    sushi[i+1][1][j+v[i]]=true;
                }else if(sushi[i][1][j]){
                    sushi[i+1][0][j]=true;
                }
            }
        }
loop1:  for(int i=total; i>0; i--){
            for(int j=0; j<2; j++){
                if(sushi[n][j][i]){
                    System.out.println(i);
                    break loop1;
                }
            }
        }
    }
}
0