結果

問題 No.73 helloworld
ユーザー kuuso1kuuso1
提出日時 2014-11-20 23:55:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 1,913 bytes
コンパイル時間 5,281 ms
コンパイル使用メモリ 105,700 KB
実行使用メモリ 22,792 KB
最終ジャッジ日時 2023-09-11 07:26:10
合計ジャッジ時間 6,979 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,648 KB
testcase_01 AC 55 ms
20,672 KB
testcase_02 AC 56 ms
22,792 KB
testcase_03 AC 57 ms
20,784 KB
testcase_04 AC 56 ms
20,764 KB
testcase_05 AC 57 ms
20,872 KB
testcase_06 AC 56 ms
20,652 KB
testcase_07 AC 56 ms
18,636 KB
testcase_08 AC 56 ms
22,676 KB
testcase_09 AC 56 ms
20,848 KB
testcase_10 AC 55 ms
20,756 KB
testcase_11 AC 56 ms
20,784 KB
testcase_12 AC 56 ms
20,768 KB
testcase_13 AC 56 ms
20,732 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		//helloworld
		//dehllloorw
		
		int[] B=new int[26];
		String hh="helloworld";
		for(int i=0;i<hh.Length;i++){
			B[hh[i]-'a']++;
		}
		
		long cnt=1;
		for(int i=0;i<26;i++){
			if(B[i]==0)continue;
			if(B[i]==1){
				cnt*=Math.Max(A[i]-B[i]+1,0);
			}
			if(B[i]>1){
				if(i==(int)('l'-'a')){
					// nC2*mC1 n+m=restのMaxを求める
					long rest=(long)(A[i]-B[i]);
					if(rest<0){
						cnt*=0;
						break;
					}
					long lmax=-1;
					for(long j=0;j<=rest;j++){
						long l=(2+j)*(2+j-1)/2;
						l*=(1+rest-j);
//Console.WriteLine(l);
						lmax=Math.Max(lmax,l);
					}
					cnt*=lmax;
				}
				if(i==(int)('o'-'a')){
					// nC1*mC1 n+m=rest+2のMaxを求める
					long rest=(long)(A[i]-B[i]);
					if(rest<0){
						cnt*=0;
						break;
					}
					long lmax=-1;
					for(long j=0;j<=rest;j++){
						long l=(1+j);
						l*=(1+rest-j);
						lmax=Math.Max(lmax,l);
					}
					cnt*=lmax;
				}
			}
		}
		
		
		Console.WriteLine(cnt);
		
		
	}
	int[] A;
	public Sol(){
		A=new int[26];
		for(int i=0;i<26;i++){
			A[i]=ri();
		}
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0