Submission #855858


Source Code Expand

Copy
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[1005][1005];
ll dp[1005];

int main() {
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  ll l,q;
  cin>>l>>q;
  vector<pair<ll,ll> > vq;
  rep(i,0,q){
    ll a,b;
    cin>>a>>b;
    vq.pb(mp(min(a,b),max(a,b)));
  }
  if(n>1000||q>1000)return 0;
  clr(d,0);
  rep(i,0,v.sz){
    rep(j,i+1,v.sz){
      if(v[j]-v[i]<=l){
        d[i][j] = 1;
      }
    }
  }
  rep(i,0,1005)dp[i] = 100000;
  dp[0] = 0;
  rep(i,0,v.sz){
    rep(j,i+1,v.sz){
      if(d[i][j]==1){
        dp[j] = min(dp[j],dp[i]+1);
      }
    }
  }
  rep(i,0,vq.sz){
    ll a = vq[i].fi;
    ll b = vq[i].se;
    cout << dp[b]-dp[a] << endl;
  }
  return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User nmnmnmnmnmnmnm
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1482 Byte
Status WA
Exec Time 185 ms
Memory 8192 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 1
AC × 1
WA × 13
AC × 1
WA × 26
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 16 ms 8192 KB
subtask1_01.txt WA 15 ms 8192 KB
subtask1_02.txt WA 14 ms 8192 KB
subtask1_03.txt WA 22 ms 8192 KB
subtask1_04.txt WA 23 ms 8192 KB
subtask1_05.txt WA 26 ms 8192 KB
subtask1_06.txt WA 18 ms 8192 KB
subtask1_07.txt WA 21 ms 8192 KB
subtask1_08.txt WA 23 ms 8192 KB
subtask1_09.txt WA 22 ms 8192 KB
subtask1_10.txt WA 26 ms 8192 KB
subtask1_11.txt WA 27 ms 8192 KB
subtask1_12.txt WA 23 ms 8192 KB
subtask1_13.txt WA 22 ms 8192 KB
subtask2_01.txt WA 159 ms 3188 KB
subtask2_02.txt WA 179 ms 3188 KB
subtask2_03.txt WA 181 ms 3188 KB
subtask2_04.txt WA 118 ms 1912 KB
subtask2_05.txt WA 118 ms 1912 KB
subtask2_06.txt WA 185 ms 3188 KB
subtask2_07.txt WA 180 ms 3188 KB
subtask2_08.txt WA 175 ms 3188 KB
subtask2_09.txt WA 182 ms 3188 KB
subtask2_10.txt WA 178 ms 3188 KB
subtask2_11.txt WA 175 ms 3188 KB
subtask2_12.txt WA 165 ms 3188 KB
subtask2_13.txt WA 173 ms 3188 KB