Submission #856794


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int N, L, Q, a, b, cur, c, ans;
    vector<int>::iterator yam;
    vector<int> x;

    cin >> N;
    x.push_back(0);
    for(int i = 0; i < N; i++){
        cin >> c;
        x.push_back(c);
    }
    cin >> L;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        ans = 1;
        cin >> a >> b;
        if(a > b)swap(a, b);
        cur = x[a];
        yam = x.begin();
        while(1){
            yam = (upper_bound(yam, x.end(), cur + L) - 1);
            cur = *yam;
            if(cur >= x[b])break;
            else ans++;
        }
        cout << ans << endl;
        //cout << cur << endl;
        //cout << x[a] << " " << x[b] << endl;
    }
       



    return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User kay
Language C++14 (GCC 5.4.1)
Score 0
Code Size 813 Byte
Status RE
Exec Time 203 ms
Memory 256 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 100
Status
RE × 4
RE × 12
RE × 24
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 example_01.txt, example_02.txt, example_03.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
All example_01.txt, example_02.txt, example_03.txt, example_04.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, 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
Case Name Status Exec Time Memory
example_01.txt RE 203 ms 256 KB
example_02.txt RE 189 ms 256 KB
example_03.txt RE 192 ms 256 KB
example_04.txt RE 200 ms 256 KB
subtask1_01.txt RE 199 ms 256 KB
subtask1_02.txt RE 188 ms 256 KB
subtask1_03.txt RE 194 ms 256 KB
subtask1_04.txt RE 197 ms 256 KB
subtask1_05.txt RE 189 ms 256 KB
subtask1_06.txt RE 194 ms 256 KB
subtask1_07.txt RE 189 ms 256 KB
subtask1_08.txt RE 193 ms 256 KB
subtask1_09.txt RE 193 ms 256 KB
subtask2_01.txt RE 195 ms 256 KB
subtask2_02.txt RE 197 ms 256 KB
subtask2_03.txt RE 196 ms 256 KB
subtask2_04.txt RE 194 ms 256 KB
subtask2_05.txt RE 191 ms 256 KB
subtask2_06.txt RE 194 ms 256 KB
subtask2_07.txt RE 193 ms 256 KB
subtask2_08.txt RE 192 ms 256 KB
subtask2_09.txt RE 195 ms 256 KB
subtask2_10.txt RE 191 ms 256 KB
subtask2_11.txt RE 197 ms 256 KB