結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー takimoto111takimoto111
提出日時 2018-04-20 18:35:42
言語 PHP
(8.3.4)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 18,612 KB
実行使用メモリ 39,264 KB
最終ジャッジ日時 2023-09-09 12:02:56
合計ジャッジ時間 1,584 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
18,900 KB
testcase_01 AC 15 ms
18,828 KB
testcase_02 AC 15 ms
18,772 KB
testcase_03 AC 15 ms
18,720 KB
testcase_04 AC 15 ms
18,828 KB
testcase_05 AC 15 ms
18,968 KB
testcase_06 AC 15 ms
18,888 KB
testcase_07 AC 16 ms
18,720 KB
testcase_08 AC 21 ms
22,936 KB
testcase_09 AC 26 ms
27,020 KB
testcase_10 AC 45 ms
39,084 KB
testcase_11 AC 46 ms
39,092 KB
testcase_12 AC 47 ms
39,212 KB
testcase_13 AC 47 ms
39,264 KB
testcase_14 AC 48 ms
39,084 KB
testcase_15 AC 49 ms
39,132 KB
testcase_16 AC 51 ms
39,124 KB
testcase_17 AC 15 ms
18,760 KB
testcase_18 AC 15 ms
18,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php


// 標準入力を一行ずつ配列に代入します
while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}

// 配列を展開
$i = 1;
foreach ($tmp as $value){
 
 //1行目
 if ($i == 1){
     //$num = $value; // 標準入力からの入力値を変数に代入
     //echo "個数は".$num."個\n";
     
 //2行目
 } elseif ($i==2){
     $array = explode(" ", $value); // 取得した入力値を半角スペースで分解
     
     // 配列を展開
     $num = 0;
     foreach($array as $int){
       //echo $int;
       $num += $int;
       
     }
     
     
     
 }
 
 $i++;
}

echo $num;
0