Submission #856131


Source Code Expand

Copy
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define DEBUG cout<<"shllhs"<<endl;
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 2005
#define INF 100000000000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-10
#define pi acos(-1.0)
using namespace std;
typedef pair<pair<int,int>,int> tri;
typedef pair<pair<ll,ll>,ll> trl;
typedef pair<int,int> pri;
typedef pair<ll,ll> prl;

int x[N];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l,q;
    while(cin>>n)
    {
        FOR(i,1,n)cin>>x[i];
        cin>>l>>q;
        FOR(i,1,q)
        {
            int a,b;
            cin>>a>>b;
            if(a>b)swap(a,b);
            int t = 0,p = a;
            while(p<b)
            {
                int tp = p;
                while(tp<b&&x[tp]-x[p]<=l)tp++;
                if(x[tp]-x[p]>l)tp--;
                p = tp;
                t++;
            }
            cout<<t<<endl;
        }
    }
    return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User shllhs
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1215 Byte
Status TLE
Exec Time 3157 ms
Memory 896 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 15
TLE × 12
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 AC 5 ms 256 KB
subtask1_03.txt AC 10 ms 256 KB
subtask1_04.txt AC 13 ms 256 KB
subtask1_05.txt AC 11 ms 256 KB
subtask1_06.txt AC 8 ms 256 KB
subtask1_07.txt AC 7 ms 256 KB
subtask1_08.txt AC 11 ms 256 KB
subtask1_09.txt AC 11 ms 256 KB
subtask1_10.txt AC 13 ms 256 KB
subtask1_11.txt AC 13 ms 256 KB
subtask1_12.txt AC 13 ms 256 KB
subtask1_13.txt AC 12 ms 256 KB
subtask2_01.txt TLE 3153 ms 896 KB
subtask2_02.txt TLE 3153 ms 768 KB
subtask2_03.txt TLE 3153 ms 768 KB
subtask2_04.txt AC 2517 ms 640 KB
subtask2_05.txt TLE 3153 ms 640 KB
subtask2_06.txt TLE 3153 ms 768 KB
subtask2_07.txt TLE 3153 ms 896 KB
subtask2_08.txt TLE 3153 ms 768 KB
subtask2_09.txt TLE 3157 ms 768 KB
subtask2_10.txt TLE 3153 ms 640 KB
subtask2_11.txt TLE 3157 ms 640 KB
subtask2_12.txt TLE 3153 ms 640 KB
subtask2_13.txt TLE 3153 ms 768 KB