結果

問題 No.258 回転寿司(2)
ユーザー kou6839kou6839
提出日時 2015-08-03 14:54:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 85,608 KB
実行使用メモリ 45,584 KB
最終ジャッジ日時 2024-04-24 11:09:19
合計ジャッジ時間 17,174 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 189 ms
45,584 KB
testcase_01 AC 196 ms
43,668 KB
testcase_02 AC 186 ms
44,856 KB
testcase_03 AC 159 ms
42,420 KB
testcase_04 AC 174 ms
42,820 KB
testcase_05 AC 184 ms
42,632 KB
testcase_06 AC 202 ms
44,344 KB
testcase_07 AC 162 ms
42,780 KB
testcase_08 AC 188 ms
44,408 KB
testcase_09 AC 151 ms
42,956 KB
testcase_10 AC 156 ms
42,712 KB
testcase_11 AC 160 ms
42,468 KB
testcase_12 AC 172 ms
42,624 KB
testcase_13 AC 158 ms
42,336 KB
testcase_14 AC 201 ms
43,048 KB
testcase_15 AC 164 ms
42,940 KB
testcase_16 AC 147 ms
42,300 KB
testcase_17 AC 154 ms
42,096 KB
testcase_18 AC 205 ms
45,220 KB
testcase_19 AC 147 ms
42,536 KB
testcase_20 AC 195 ms
45,160 KB
testcase_21 AC 204 ms
44,140 KB
testcase_22 AC 145 ms
42,560 KB
testcase_23 AC 149 ms
42,312 KB
testcase_24 AC 131 ms
42,412 KB
testcase_25 AC 156 ms
42,588 KB
testcase_26 AC 197 ms
44,752 KB
testcase_27 AC 169 ms
42,692 KB
testcase_28 AC 191 ms
44,448 KB
testcase_29 AC 149 ms
43,120 KB
testcase_30 AC 154 ms
42,548 KB
testcase_31 AC 158 ms
42,576 KB
testcase_32 AC 165 ms
42,480 KB
testcase_33 AC 193 ms
44,848 KB
testcase_34 AC 191 ms
43,308 KB
testcase_35 AC 195 ms
44,500 KB
testcase_36 AC 150 ms
42,648 KB
testcase_37 AC 149 ms
42,648 KB
testcase_38 AC 169 ms
42,824 KB
testcase_39 AC 169 ms
42,988 KB
testcase_40 AC 182 ms
44,660 KB
testcase_41 AC 192 ms
43,060 KB
testcase_42 AC 170 ms
42,796 KB
testcase_43 AC 151 ms
42,600 KB
testcase_44 AC 183 ms
44,960 KB
testcase_45 AC 190 ms
44,696 KB
testcase_46 AC 140 ms
42,336 KB
testcase_47 AC 190 ms
43,020 KB
testcase_48 AC 144 ms
42,452 KB
testcase_49 AC 162 ms
42,824 KB
testcase_50 AC 149 ms
42,464 KB
testcase_51 AC 191 ms
44,980 KB
testcase_52 AC 179 ms
43,192 KB
testcase_53 AC 150 ms
42,548 KB
testcase_54 AC 188 ms
44,920 KB
testcase_55 AC 185 ms
44,264 KB
testcase_56 AC 182 ms
43,372 KB
testcase_57 AC 160 ms
42,768 KB
testcase_58 AC 192 ms
44,408 KB
testcase_59 AC 199 ms
44,460 KB
testcase_60 AC 151 ms
42,560 KB
testcase_61 AC 203 ms
44,988 KB
testcase_62 AC 164 ms
42,920 KB
testcase_63 AC 187 ms
44,020 KB
testcase_64 AC 202 ms
45,040 KB
testcase_65 AC 191 ms
44,624 KB
testcase_66 AC 140 ms
42,608 KB
testcase_67 AC 192 ms
44,568 KB
testcase_68 AC 195 ms
43,844 KB
testcase_69 AC 194 ms
43,020 KB
testcase_70 AC 171 ms
42,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.net.NetworkInterface;
import java.util.*;

import javax.swing.event.AncestorEvent;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] susi = new int[n+1];
		for(int i=1;i<=n;i++) susi[i]=sc.nextInt();
		int[] dp = new int[n+1];
		dp[1]=susi[1];
		int max = dp[1];
		for(int i=2;i<=n;i++){
			dp[i]=Math.max(dp[i-1], dp[i-2]+susi[i]);
			max=Math.max(max, dp[i]);
		}
		ArrayList<Integer> get  = new ArrayList<>();
		int index = n;
		while(index>0){
			if(dp[index]==dp[index-1]){
				index--;
			}else{
				get.add(index);
				index-=2;
			}
		}
		String aaa = "";
		Collections.reverse(get);
		for(int a:get) aaa+=a+" ";
		System.out.println(max);
		System.out.println(aaa.trim());
	}
}
0