結果

問題 No.73 helloworld
ユーザー scachescache
提出日時 2014-11-23 20:17:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 935 bytes
コンパイル時間 3,763 ms
コンパイル使用メモリ 77,676 KB
実行使用メモリ 41,240 KB
最終ジャッジ日時 2024-06-28 21:55:53
合計ジャッジ時間 6,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main73 {
	public static void main(String[] args) {
		Main73 p = new Main73();
	}

	public Main73() {
		Scanner sc = new Scanner(System.in);
		
		long[] c = new long[26];
		for (int i = 0; i < c.length; i++) 
			c[i] = sc.nextLong();
		
		solve(c);
		
	}

	public void solve(long[] c) {
		long res = 0;
		
		if(c['h'-'a']>0 && c['e'-'a'] > 0 && c['l'-'a'] > 2 && c['o'-'a'] > 1 && c['w'-'a'] > 0 && c['r'-'a'] > 0 && c['d'-'a'] > 0)		
			res = c['h'-'a'] * c['e'-'a'] * lcalc(c['l'-'a']) 
					* ocalc(c['o'-'a']) * c['w'-'a'] * c['r'-'a']* c['d'-'a'];
		
		System.out.println(res);
	}
	
	private long lcalc(long n){
		long m = 0;
		for(int i=1;i<n;i++){
			m = Math.max(m, (n-i)*(n-i-1)/2 * i);
		}
		
		return m;
	}
	
	private long ocalc(long n){
		long m = 0;
		for(int i=1;i<n;i++){
			m = Math.max(m, (n-i)*i);
		}
		
		return m;
	}
	
	

}
0