結果

問題 No.118 門松列(2)
ユーザー 37zigen
提出日時 2020-02-18 11:41:46
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 604 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 75,688 KB
実行使用メモリ 59,524 KB
最終ジャッジ日時 2024-10-06 15:28:38
合計ジャッジ時間 12,510 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	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) {
			dp[2]+=dp[1]*cnt[i];
			dp[1]+=dp[0]*cnt[i];
			dp[0]+=cnt[i];
		}
		System.out.println(dp[2]);
		
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0