Submission #855840


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

const int INF = 1 << 28;
int main() {
    int N;
    cin >> N;
    vector<int> x(N);
    for (auto& i : x) cin >> i;
    int L, Q;
    cin >> L >> Q;

    while (Q--) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (a > b) swap(a, b);

        vector<int> dp(N, INF);
        dp[a] = 0;
        for (int i = a; i < b; i++) {
            for (int j = i + 1; x[j] - x[i] <= L; j++) {
                dp[j] = min(dp[j], dp[i]+1);
            }
        }

        cout << dp[b] << endl;
    }

    return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User wanimaru47
Language C++14 (GCC 5.4.1)
Score 0
Code Size 608 Byte
Status TLE
Exec Time 3153 ms
Memory 1144 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 1
AC × 4
RE × 10
AC × 4
TLE × 10
RE × 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 4 ms 256 KB
subtask1_01.txt AC 4 ms 256 KB
subtask1_02.txt RE 189 ms 384 KB
subtask1_03.txt AC 19 ms 256 KB
subtask1_04.txt RE 188 ms 384 KB
subtask1_05.txt RE 188 ms 384 KB
subtask1_06.txt RE 191 ms 384 KB
subtask1_07.txt RE 187 ms 384 KB
subtask1_08.txt RE 187 ms 384 KB
subtask1_09.txt RE 188 ms 384 KB
subtask1_10.txt RE 187 ms 384 KB
subtask1_11.txt RE 186 ms 256 KB
subtask1_12.txt RE 190 ms 256 KB
subtask1_13.txt AC 13 ms 256 KB
subtask2_01.txt RE 2456 ms 1144 KB
subtask2_02.txt TLE 3153 ms 1144 KB
subtask2_03.txt TLE 3153 ms 1024 KB
subtask2_04.txt RE 2307 ms 768 KB
subtask2_05.txt TLE 3153 ms 768 KB
subtask2_06.txt TLE 3153 ms 1024 KB
subtask2_07.txt TLE 3153 ms 1024 KB
subtask2_08.txt RE 1758 ms 1024 KB
subtask2_09.txt TLE 3153 ms 1024 KB
subtask2_10.txt TLE 3153 ms 1024 KB
subtask2_11.txt TLE 3153 ms 1048 KB
subtask2_12.txt TLE 3153 ms 1144 KB
subtask2_13.txt TLE 3153 ms 1024 KB