結果

問題 No.118 門松列(2)
ユーザー 37zigen37zigen
提出日時 2020-02-18 12:03:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 575 ms / 5,000 ms
コード長 664 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 78,400 KB
実行使用メモリ 48,324 KB
最終ジャッジ日時 2024-04-16 04:07:14
合計ジャッジ時間 13,179 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 226 ms
46,240 KB
testcase_01 AC 554 ms
48,264 KB
testcase_02 AC 567 ms
48,160 KB
testcase_03 AC 575 ms
48,324 KB
testcase_04 AC 574 ms
48,224 KB
testcase_05 AC 536 ms
48,208 KB
testcase_06 AC 132 ms
41,288 KB
testcase_07 AC 129 ms
41,328 KB
testcase_08 AC 131 ms
41,612 KB
testcase_09 AC 567 ms
48,140 KB
testcase_10 AC 293 ms
47,424 KB
testcase_11 AC 330 ms
47,800 KB
testcase_12 AC 262 ms
46,664 KB
testcase_13 AC 222 ms
46,344 KB
testcase_14 AC 562 ms
48,280 KB
testcase_15 AC 194 ms
43,628 KB
testcase_16 AC 445 ms
48,096 KB
testcase_17 AC 232 ms
45,940 KB
testcase_18 AC 333 ms
47,600 KB
testcase_19 AC 410 ms
48,028 KB
testcase_20 AC 431 ms
48,172 KB
testcase_21 AC 549 ms
47,952 KB
testcase_22 AC 300 ms
47,648 KB
testcase_23 AC 507 ms
48,116 KB
testcase_24 AC 351 ms
48,120 KB
testcase_25 AC 363 ms
46,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	final long m=(long)1e9+7;
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] cnt=new int[101];
		for(int i=0;i<N;++i) {
			int a=sc.nextInt();
			cnt[a]++;
		}
		long[] dp=new long[3];
		for(int i=0;i<cnt.length;++i) {
			if(cnt[i]==0)continue;
			dp[2]+=dp[1]*cnt[i]%m;
			dp[1]+=dp[0]*cnt[i]%m;
			dp[0]+=cnt[i];
			for(int j=0;j<3;++j)dp[j]%=m;
		}
		System.out.println(dp[2]);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0