結果

問題 No.29 パワーアップ
ユーザー mondomondo
提出日時 2019-07-29 12:44:30
言語 PHP
(843.2)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 717 bytes
コンパイル時間 1,160 ms
コンパイル使用メモリ 30,800 KB
実行使用メモリ 31,296 KB
最終ジャッジ日時 2024-07-02 15:16:29
合計ジャッジ時間 2,597 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
    $n = trim(fgets(STDIN));
    $items = array();
    for($i = 0; $i < $n; $i++){
        $item = explode(" ", trim(fgets(STDIN)));
        $items = array_merge($items, $item);
    }
    $levelup = 0;
    $level = array();
    // $levelに$itemsを代入していく⇒重複した値が来たときは$upをカウントし
    // 重複した値はunset関数で削除する
    // $levelに残った要素を4で割る
    foreach ($items as $value) {
        if(in_array($value, $level)){
            $levelup++;
            $key = array_search($value, $level);
            unset($level[$key]);
        }else{
            $level[] = $value;
        }
    }
    echo $levelup + floor(count($level) / 4)."\n";
0