Submission #7389865


Source Code Expand

Copy
<?php
fscanf(STDIN, '%d', $n);
$b = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = 0;
for ($i = 0; $i < $n; $i++) {
    $ans += min($b[$i - 1] ?? $b[$i], $b[$i] ?? $b[$i - 1]);
}
echo $ans . PHP_EOL;

Submission Info

Submission Time
Task C - Maximal Value
User hideyuk1
Language PHP7 (7.0.15)
Score 300
Code Size 221 Byte
Status
Exec Time 13 ms
Memory 4728 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample00, sample01, sample02
All 300 / 300 handmade03, handmade04, handmade05, handmade06, handmade07, handmade08, handmade09, random10, random11, random12, random13, random14, sample00, sample01, sample02
Case Name Status Exec Time Memory
handmade03 13 ms 4728 KB
handmade04 9 ms 4604 KB
handmade05 9 ms 4604 KB
handmade06 9 ms 4604 KB
handmade07 9 ms 4604 KB
handmade08 9 ms 4604 KB
handmade09 9 ms 4604 KB
random10 9 ms 4604 KB
random11 9 ms 4604 KB
random12 9 ms 4604 KB
random13 9 ms 4604 KB
random14 9 ms 4604 KB
sample00 9 ms 4604 KB
sample01 9 ms 4604 KB
sample02 9 ms 4604 KB