Submission #7529757


Source Code Expand

Copy
<?php
fscanf(STDIN, '%d %d', $n, $m);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$q = new SplPriorityQueue;
for ($i = 0; $i < $n; $i++) {
    $q->insert($a[$i], $a[$i]);
}
$i = 0;
while ($i < $m) {
    $x = $q->extract();
    $x = $x / 2;
    $q->insert($x, $x);
    $i++;
}
$ans = 0;
while ($q->count() > 0) {
    $ans += (int)floor($q->extract());
}
echo $ans . PHP_EOL;

Submission Info

Submission Time
Task D - Powerful Discount Tickets
User hideyuk1
Language PHP7 (7.0.15)
Score 400
Code Size 407 Byte
Status
Exec Time 844 ms
Memory 53748 KB

Test Cases

Set Name Score / Max Score Test Cases
All 400 / 400 sample_01, sample_02, sample_03, sample_04, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19
Sample 0 / 0 sample_01, sample_02, sample_03, sample_04
Case Name Status Exec Time Memory
sample_01 12 ms 4728 KB
sample_02 9 ms 4604 KB
sample_03 37 ms 4604 KB
sample_04 9 ms 4604 KB
testcase_01 277 ms 33272 KB
testcase_02 185 ms 8696 KB
testcase_03 483 ms 51700 KB
testcase_04 844 ms 53748 KB
testcase_05 123 ms 27128 KB
testcase_06 577 ms 47604 KB
testcase_07 53 ms 14840 KB
testcase_08 366 ms 53748 KB
testcase_09 449 ms 35320 KB
testcase_10 146 ms 12792 KB
testcase_11 390 ms 41460 KB
testcase_12 735 ms 53748 KB
testcase_13 154 ms 6648 KB
testcase_14 262 ms 53748 KB
testcase_15 735 ms 53748 KB
testcase_16 211 ms 10744 KB
testcase_17 9 ms 4604 KB
testcase_18 9 ms 4604 KB
testcase_19 93 ms 53748 KB