#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "rail.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int n,i,q,l[nmax],r[nmax],x,y,h[nmax],ans,a,b,j,a1,b1,rs[2050][2050];
int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)cin>>h[i]>>l[i]>>r[i];
for(i=1;i<=n;i++)
{
a=l[i],b=r[i];
ans=-1;
for(j=i+1;j<=n;j++)
{
a1=l[j],b1=r[j];
if(((i+a<=j && i+b>=j) || (i-a>=j && i-b<=j)) && ((j+a1<=i && j+b1>=i) || (j-a1>=i && j-b1<=i)))
{
ans=max(ans,abs(h[j]-h[i]));
rs[i][j]=ans;
}
}
}
for(i=2;i<=n;i++)
{
for(j=1;j<=n-i+1;j++)
{
rs[j][j+i-1]=max(rs[j][j+i-1],max(rs[j+1][j+i-1],rs[j][j+i-2]));
}
}
cin>>q;
while(q--)
{
cin>>x>>y;
cout<<rs[x][y]<<'\n';
}
return 0;
}
Compilation message
antennas.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
antennas.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1449 ms |
38688 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |