結果

問題 No.1470 Mex Sum
ユーザー KFrom40KFrom40
提出日時 2021-04-15 21:49:40
言語 PHP
(8.3.4)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 18,656 KB
実行使用メモリ 37,064 KB
最終ジャッジ日時 2023-09-14 23:50:38
合計ジャッジ時間 4,072 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
18,868 KB
testcase_01 AC 16 ms
18,864 KB
testcase_02 AC 18 ms
20,812 KB
testcase_03 AC 18 ms
20,896 KB
testcase_04 AC 20 ms
20,872 KB
testcase_05 AC 21 ms
20,812 KB
testcase_06 AC 18 ms
20,852 KB
testcase_07 AC 19 ms
20,836 KB
testcase_08 AC 18 ms
20,820 KB
testcase_09 AC 19 ms
20,820 KB
testcase_10 AC 19 ms
20,652 KB
testcase_11 AC 19 ms
20,868 KB
testcase_12 AC 45 ms
36,996 KB
testcase_13 AC 44 ms
32,896 KB
testcase_14 AC 45 ms
32,920 KB
testcase_15 AC 46 ms
37,064 KB
testcase_16 AC 45 ms
32,940 KB
testcase_17 AC 44 ms
32,852 KB
testcase_18 AC 45 ms
32,876 KB
testcase_19 AC 45 ms
32,932 KB
testcase_20 AC 44 ms
32,900 KB
testcase_21 AC 46 ms
37,044 KB
testcase_22 AC 46 ms
37,004 KB
testcase_23 AC 46 ms
37,048 KB
testcase_24 AC 46 ms
37,020 KB
testcase_25 AC 46 ms
36,968 KB
testcase_26 AC 46 ms
37,048 KB
testcase_27 AC 46 ms
37,000 KB
testcase_28 AC 47 ms
37,000 KB
testcase_29 AC 46 ms
37,008 KB
testcase_30 AC 47 ms
36,824 KB
testcase_31 AC 46 ms
36,956 KB
testcase_32 AC 46 ms
36,992 KB
testcase_33 AC 46 ms
36,832 KB
testcase_34 AC 46 ms
36,972 KB
testcase_35 AC 47 ms
36,836 KB
testcase_36 AC 47 ms
36,972 KB
testcase_37 AC 40 ms
34,944 KB
testcase_38 AC 42 ms
34,944 KB
testcase_39 AC 41 ms
34,976 KB
testcase_40 AC 43 ms
34,788 KB
testcase_41 AC 42 ms
35,000 KB
testcase_42 AC 42 ms
34,916 KB
testcase_43 AC 42 ms
34,788 KB
testcase_44 AC 42 ms
34,920 KB
testcase_45 AC 42 ms
34,952 KB
testcase_46 AC 43 ms
34,904 KB
testcase_47 AC 43 ms
35,024 KB
testcase_48 AC 42 ms
34,944 KB
testcase_49 AC 43 ms
35,020 KB
testcase_50 AC 42 ms
34,972 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
//[$n,$m] = array_map('intval', explode(' ', trim(fgets(STDIN))));
[$n] = array_map('intval', explode(' ', trim(fgets(STDIN))));
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
//[$s,$t] = explode(' ', trim(fgets(STDIN)));
//[$s] = explode(' ', trim(fgets(STDIN)));
//$s = explode(' ', trim(fgets(STDIN)));
//function decr($v){return --$v;}
//alpha='abcdefghijklmnopqrstuvwxyz';

$one = 0;
$two = 0;
for($i=0;$i<$n;$i++){
    if($a[$i] == 1) $one ++;
    else if($a[$i] == 2) $two ++;
}

if($one == 0){
    echo $n * ($n-1) / 2;
    exit;
}

$other = $n - $one - $two;
$ans = $other*($other-1)/2;
$ans += $one * ($one-1)/2 * 2;
$ans += $other * $one * 2;
$ans += $one * $two * 3;
$ans += $other * $two;
$ans += $two * ($two-1)/2;

echo $ans;
0