Submission #855992


Source Code Expand

Copy
<?php
/*
    Problem URL : http://arc060.contest.atcoder.jp/tasks/arc060_c

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d %d", $N, $A);
$x = explode(" ", trim(fgets(STDIN)));
array_unshift($x, 0);
// var_dump($x);
fscanf(STDIN, "%d", $L);
fscanf(STDIN, "%d", $Q);

for ($i = 0; $i < $Q; $i++) {
    fscanf(STDIN, "%d %d", $aa, $bb);
    $ans = 0;
    // echo "==============\n";
    if ($aa < $bb) {
        // echo "type A\n";
        $pos = $x[$aa];
        // echo "init pos:$pos \n";
        // echo $pos . PHP_EOL;
        for ($j = $aa; $j <= $bb; $j++) {
            if (abs($x[$j] - $pos) <= $L) {

            } else {
                $ans++;
                $pos = $x[$j - 1];
            }
            // echo $pos . PHP_EOL;
        }
        $ans++;
        echo $ans . PHP_EOL;

    } else {
        // echo "type B\n";
        $pos = $x[$aa];
        for ($j = $aa; $j >= $bb; $j--) {
            if (abs($x[$j] - $pos) <= $L) {

            } else {
                $ans++;
                $pos = $x[$j + 1];
            }
        }
        $ans++;
        echo $ans . PHP_EOL;

    }
}

Submission Info

Submission Time
Task E - Tak and Hotels
User takepan
Language PHP (5.6.30)
Score 200
Code Size 1192 Byte
Status TLE
Exec Time 3192 ms
Memory 21932 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 14
TLE × 13
Set Name Test Cases
Sample example_01.txt
Subtask1 example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt
All example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt
Case Name Status Exec Time Memory
example_01.txt AC 29 ms 3704 KB
subtask1_01.txt AC 27 ms 3452 KB
subtask1_02.txt AC 25 ms 3452 KB
subtask1_03.txt AC 160 ms 3704 KB
subtask1_04.txt AC 227 ms 3704 KB
subtask1_05.txt AC 187 ms 3704 KB
subtask1_06.txt AC 80 ms 3576 KB
subtask1_07.txt AC 73 ms 3576 KB
subtask1_08.txt AC 196 ms 3704 KB
subtask1_09.txt AC 196 ms 3704 KB
subtask1_10.txt AC 221 ms 3704 KB
subtask1_11.txt AC 219 ms 3704 KB
subtask1_12.txt AC 213 ms 3704 KB
subtask1_13.txt AC 189 ms 3704 KB
subtask2_01.txt TLE 3159 ms 21556 KB
subtask2_02.txt TLE 3155 ms 21932 KB
subtask2_03.txt TLE 3159 ms 21932 KB
subtask2_04.txt TLE 3155 ms 15864 KB
subtask2_05.txt TLE 3159 ms 15864 KB
subtask2_06.txt TLE 3156 ms 21932 KB
subtask2_07.txt TLE 3192 ms 21932 KB
subtask2_08.txt TLE 3159 ms 21776 KB
subtask2_09.txt TLE 3159 ms 21796 KB
subtask2_10.txt TLE 3159 ms 21852 KB
subtask2_11.txt TLE 3156 ms 20480 KB
subtask2_12.txt TLE 3156 ms 21796 KB
subtask2_13.txt TLE 3159 ms 21744 KB