結果

問題 No.143 豆
ユーザー SATSUKI-UPDATESATSUKI-UPDATE
提出日時 2022-05-17 17:07:08
言語 PHP
(8.3.4)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 1,003 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 12,016 KB
実行使用メモリ 12,352 KB
最終ジャッジ日時 2023-10-13 15:10:03
合計ジャッジ時間 1,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
12,296 KB
testcase_01 AC 7 ms
12,240 KB
testcase_02 AC 8 ms
12,240 KB
testcase_03 AC 7 ms
12,236 KB
testcase_04 AC 7 ms
12,232 KB
testcase_05 AC 7 ms
12,352 KB
testcase_06 AC 8 ms
12,308 KB
testcase_07 AC 7 ms
12,248 KB
testcase_08 AC 7 ms
12,296 KB
testcase_09 AC 8 ms
12,344 KB
testcase_10 AC 8 ms
12,300 KB
testcase_11 AC 8 ms
12,232 KB
testcase_12 AC 7 ms
12,296 KB
testcase_13 AC 8 ms
12,232 KB
testcase_14 AC 8 ms
12,308 KB
testcase_15 AC 8 ms
12,236 KB
testcase_16 AC 8 ms
12,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
function getStandardInput()
{
  $array = array();
  while (true) {
    $stdin = fgets(STDIN);
    if ($stdin == "") {
      break;
    }
    $array[] = rtrim($stdin);
  }
  return $array;
}

function splitBySpace($str)
{
  return explode(' ', $str);
}

function bubbleSort($array)
{
    $cnt = count($array);

    for($i=0;$i<$cnt-1;$i++){
        for($j=$i+1;$j<$cnt;$j++){
            if($array[$i]>$array[$j]){
                $tmp = $array[$i];
                $array[$i] = $array[$j];
                $array[$j] = $tmp;
            }
        }
    }
    return $array;
}

$stdIn = getStandardInput();
$splitStdIn1 = splitBySpace($stdIn[0]);
$beanCount = $splitStdIn1[0];
$packCount = $splitStdIn1[1];
$familyCount = $splitStdIn1[2];
$remainBeanCount = $beanCount * $packCount;

$familyAges = splitBySpace($stdIn[1]);

foreach ($familyAges as $familyAge){
    $remainBeanCount = $remainBeanCount - $familyAge;
}

if($remainBeanCount < 0){
    echo(-1);
} else {
    echo($remainBeanCount);
}

0