結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー phptarophptaro
提出日時 2015-02-28 17:06:53
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 1,058 ms
コンパイル使用メモリ 18,772 KB
実行使用メモリ 92,720 KB
最終ジャッジ日時 2023-09-03 16:49:42
合計ジャッジ時間 8,319 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
23,064 KB
testcase_01 AC 15 ms
18,792 KB
testcase_02 AC 15 ms
18,856 KB
testcase_03 AC 16 ms
18,672 KB
testcase_04 AC 15 ms
18,820 KB
testcase_05 AC 16 ms
18,816 KB
testcase_06 AC 16 ms
18,752 KB
testcase_07 WA -
testcase_08 AC 15 ms
18,772 KB
testcase_09 AC 15 ms
18,820 KB
testcase_10 AC 15 ms
18,900 KB
testcase_11 AC 15 ms
18,816 KB
testcase_12 AC 16 ms
18,820 KB
testcase_13 WA -
testcase_14 AC 15 ms
18,804 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$num = rtrim(fgets(STDIN), PHP_EOL);
$points = trim(fgets(STDIN));
$arr = explode(" ", $points);

$ans = array();
//var_dump($arr);


for ($j = 0; $j < $num; $j++) {
	$arr2 = array_fill(0, max($arr) +1, false);	//全てfalseでうめる
	$L = $j;	//範囲の始まり
	$arr2[$arr[$L]] = true;
	//var_dump($arr2);
	for ($k = $j+1; $k < $num; $k++) {
		$R = $k;	//範囲の終わり
		if($arr2[$arr[$R]] === false){
			$arr2[$arr[$R]] = true;
			//echo "true L:$L R:$R"." $arr[$L] $arr[$R]"."\n";
		}else{
			//echo "false L:$L R:$R"." $arr[$L] $arr[$R]"."\n";
			$ans[] = $R - $L;
			break;
		}
		
	}
}
//var_dump($ans);
//var_dump($arr2);

if(count($ans) == 0){
	$answer = $num;
}else{
	$answer = max($ans);
}

echo $answer."\n";
0