Submission #67248374


Source Code Expand

<?php

declare(strict_types=1);

/**
 * メイン処理関数
 */
function main(): void {
    $stdin = fopen('php://stdin', 'r');
    if ($stdin === false) {
        throw new RuntimeException("Failed to open stdin.");
    }

    /** @var int $T 営業終了時間 */
    $T = (int)fgets($stdin);
    /** @var int $N 従業員数 */
    $N = (int)fgets($stdin);

    /** @var array<int> $cnt 差分配列 */
    $cnt = array_fill(0, $T + 1, 0);

    // 差分配列への反映
    for ($i = 0; $i < $N; $i++) {
        $line = fgets($stdin);
        if ($line === false) {
            throw new RuntimeException("Failed to read line.");
        }
        [$L, $R] = array_map('intval', explode(' ', trim($line)));
        $cnt[$L] += 1;
        $cnt[$R] -= 1;
    }

    // 累積和と出力
    $current = 0;
    for ($t = 0; $t < $T; $t++) {
        $current += $cnt[$t];
        echo $current . "\n";
    }

    fclose($stdin);
}

main();

Submission Info

Submission Time
Task B07 - Convenience Store 2
User myoshizumi
Language PHP (php 8.2.8)
Score 1000
Code Size 987 Byte
Status AC
Exec Time 639 ms
Memory 29068 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 1
AC × 16
Set Name Test Cases
Sample sample-01.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, sample-01.txt
Case Name Status Exec Time Memory
01-01.txt AC 178 ms 21448 KiB
01-02.txt AC 135 ms 22212 KiB
01-03.txt AC 430 ms 25544 KiB
01-04.txt AC 639 ms 28928 KiB
01-05.txt AC 636 ms 28704 KiB
01-06.txt AC 630 ms 29068 KiB
01-07.txt AC 124 ms 21400 KiB
01-08.txt AC 580 ms 28808 KiB
01-09.txt AC 583 ms 28680 KiB
01-10.txt AC 295 ms 25336 KiB
01-11.txt AC 445 ms 28552 KiB
01-12.txt AC 508 ms 28240 KiB
01-13.txt AC 168 ms 23448 KiB
01-14.txt AC 586 ms 28768 KiB
01-15.txt AC 593 ms 28944 KiB
sample-01.txt AC 17 ms 21204 KiB