#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
long long INF=numeric_limits<long long>::max();
ll n,h,a,b,q,lft,rgt;
ll hgt[200222];
pll rng[200222];
vll adj[2002];
ll cost[2002][2002];
int check(int i, int j)
{
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
cin >> n;
for(ll i=0; i<n; i++){
cin >> h >> a >> b;
hgt[i] = h;
//left
for(ll j=a; j<=b; j++){
if(i-j>=0){
adj[i-j].pb(i);
}
else break;
}
//right
for(ll j=a; j<=b; j++){
if(i+j<n){
adj[i+j].pb(i);
}
else break;
}
}
/*
cout << " *** " << endl;
for(int i=0; i<n; i++){
for(int j=0; j<adj[i].size(); j++){
cout << adj[i][j] << " " ;
}
cout << endl;
}
cout << " *** " << endl;
*/
for(int i=0; i<n; i++){
for(int j = i+1; j<n; j++){
if(binary_search(adj[i].begin(),adj[i].end(),j)&&binary_search(adj[j].begin(),adj[j].end(),i)){
cost[i][j] = abs(hgt[i] - hgt[j]);
}
}
}
cin >> q;
for(ll i=0; i<q; i++){
ll ans = -1;
cin >> lft >> rgt;
lft--; rgt--;
for(ll j=lft; j<=rgt; j++){
for(ll k=j+1; k<=rgt; k++){
if(cost[j][k])ans = max(cost[j][k],ans);
}
}
cout << ans << endl;
}
}
Compilation message
antennas.cpp: In function 'int check(int, int)':
antennas.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
1536 KB |
Output is correct |
3 |
Correct |
5 ms |
1152 KB |
Output is correct |
4 |
Correct |
7 ms |
1408 KB |
Output is correct |
5 |
Correct |
1 ms |
1152 KB |
Output is correct |
6 |
Correct |
8 ms |
1408 KB |
Output is correct |
7 |
Correct |
8 ms |
1152 KB |
Output is correct |
8 |
Correct |
8 ms |
1408 KB |
Output is correct |
9 |
Correct |
4 ms |
768 KB |
Output is correct |
10 |
Correct |
6 ms |
1536 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
8 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1024 KB |
Output is correct |
14 |
Correct |
7 ms |
1024 KB |
Output is correct |
15 |
Correct |
6 ms |
1152 KB |
Output is correct |
16 |
Correct |
5 ms |
1024 KB |
Output is correct |
17 |
Correct |
5 ms |
1024 KB |
Output is correct |
18 |
Correct |
7 ms |
1024 KB |
Output is correct |
19 |
Correct |
4 ms |
1024 KB |
Output is correct |
20 |
Correct |
6 ms |
1024 KB |
Output is correct |
21 |
Correct |
6 ms |
1024 KB |
Output is correct |
22 |
Correct |
6 ms |
1024 KB |
Output is correct |
23 |
Correct |
5 ms |
1024 KB |
Output is correct |
24 |
Correct |
5 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
1536 KB |
Output is correct |
3 |
Correct |
5 ms |
1152 KB |
Output is correct |
4 |
Correct |
7 ms |
1408 KB |
Output is correct |
5 |
Correct |
1 ms |
1152 KB |
Output is correct |
6 |
Correct |
8 ms |
1408 KB |
Output is correct |
7 |
Correct |
8 ms |
1152 KB |
Output is correct |
8 |
Correct |
8 ms |
1408 KB |
Output is correct |
9 |
Correct |
4 ms |
768 KB |
Output is correct |
10 |
Correct |
6 ms |
1536 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
8 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1024 KB |
Output is correct |
14 |
Correct |
7 ms |
1024 KB |
Output is correct |
15 |
Correct |
6 ms |
1152 KB |
Output is correct |
16 |
Correct |
5 ms |
1024 KB |
Output is correct |
17 |
Correct |
5 ms |
1024 KB |
Output is correct |
18 |
Correct |
7 ms |
1024 KB |
Output is correct |
19 |
Correct |
4 ms |
1024 KB |
Output is correct |
20 |
Correct |
6 ms |
1024 KB |
Output is correct |
21 |
Correct |
6 ms |
1024 KB |
Output is correct |
22 |
Correct |
6 ms |
1024 KB |
Output is correct |
23 |
Correct |
5 ms |
1024 KB |
Output is correct |
24 |
Correct |
5 ms |
1024 KB |
Output is correct |
25 |
Execution timed out |
3007 ms |
5200 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
3840 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Correct |
8 ms |
1536 KB |
Output is correct |
3 |
Correct |
5 ms |
1152 KB |
Output is correct |
4 |
Correct |
7 ms |
1408 KB |
Output is correct |
5 |
Correct |
1 ms |
1152 KB |
Output is correct |
6 |
Correct |
8 ms |
1408 KB |
Output is correct |
7 |
Correct |
8 ms |
1152 KB |
Output is correct |
8 |
Correct |
8 ms |
1408 KB |
Output is correct |
9 |
Correct |
4 ms |
768 KB |
Output is correct |
10 |
Correct |
6 ms |
1536 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
8 ms |
1408 KB |
Output is correct |
13 |
Correct |
5 ms |
1024 KB |
Output is correct |
14 |
Correct |
7 ms |
1024 KB |
Output is correct |
15 |
Correct |
6 ms |
1152 KB |
Output is correct |
16 |
Correct |
5 ms |
1024 KB |
Output is correct |
17 |
Correct |
5 ms |
1024 KB |
Output is correct |
18 |
Correct |
7 ms |
1024 KB |
Output is correct |
19 |
Correct |
4 ms |
1024 KB |
Output is correct |
20 |
Correct |
6 ms |
1024 KB |
Output is correct |
21 |
Correct |
6 ms |
1024 KB |
Output is correct |
22 |
Correct |
6 ms |
1024 KB |
Output is correct |
23 |
Correct |
5 ms |
1024 KB |
Output is correct |
24 |
Correct |
5 ms |
1024 KB |
Output is correct |
25 |
Execution timed out |
3007 ms |
5200 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |