This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef std::vector<ll> vi;
typedef pair < ll , ll > pll;
#define pb push_back
#define mp make_pair
ll mx(ll a , ll b){
if (a > b) return a;
return b;
}
ll mod (ll x ){
if (x % 998244353 < 0) return(mod (x + 998244353));
return x % 998244353 ;
}
ll pw(ll x , ll p){
ll r = 1;
while (p > 0){
if (p & 1){
r *= x;
r = mod(r);
p --;
}
x *= x;
x = mod(x);
p /= 2;
}
return r;
}
ll n , q;
vi hi , ai , bi;
void solve(ll l , ll r){
ll res = -1;
for (ll i = l ; i <= r ; i ++){
for (ll j = i + 1 ; j <= r ; j ++){
ll d = j - i;
if (d >= ai[i-1] and bi[i-1] >= d and d >= ai[j-1] and bi[j-1] >= d){
res = mx(abs(hi[i-1]-hi[j-1]) , res);
}
}
}
cout << res << endl;
}
int main(){
cin >> n;
for (ll i = 0 ; i < n ; i ++){
ll h , a , b;
cin >> h >> a >> b;
hi.pb(h);
ai.pb(a);
bi.pb(b);
}
cin >> q;
for (ll i = 0 ; i < q ; i ++){
ll l , r;
cin >> l >> r;
solve(l , r);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |