Contest Duration: - (local time) (100 minutes) Back to Home

Submission #855615

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;
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 2016-08-28 21:26:30+0900 E - Tak and Hotels nmnmnmnmnmnmnm C++14 (GCC 5.4.1) 0 1469 Byte WA 181 ms 7168 KB

#### Judge Result

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
Case Name Status Exec Time Memory
example_01.txt AC 4 ms 256 KB
subtask1_01.txt WA 5 ms 256 KB
subtask1_02.txt WA 4 ms 256 KB
subtask1_03.txt WA 21 ms 4224 KB
subtask1_04.txt WA 19 ms 4224 KB
subtask1_05.txt WA 22 ms 4864 KB
subtask1_06.txt WA 11 ms 2304 KB
subtask1_07.txt WA 11 ms 2688 KB
subtask1_08.txt WA 25 ms 7168 KB
subtask1_09.txt WA 22 ms 4352 KB
subtask1_10.txt WA 22 ms 4352 KB
subtask1_11.txt WA 22 ms 4352 KB
subtask1_12.txt WA 22 ms 4352 KB
subtask1_13.txt WA 20 ms 4096 KB
subtask2_01.txt WA 170 ms 3188 KB
subtask2_02.txt WA 181 ms 3188 KB
subtask2_03.txt WA 181 ms 3188 KB
subtask2_04.txt WA 123 ms 1912 KB
subtask2_05.txt WA 118 ms 1912 KB
subtask2_06.txt WA 180 ms 3188 KB
subtask2_07.txt WA 179 ms 3188 KB
subtask2_08.txt WA 175 ms 3188 KB
subtask2_09.txt WA 175 ms 3188 KB
subtask2_10.txt WA 178 ms 3188 KB
subtask2_11.txt WA 176 ms 3188 KB
subtask2_12.txt WA 165 ms 3188 KB
subtask2_13.txt WA 172 ms 3188 KB