이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
#define GEN 0
int main(){
srand(time(NULL));
int n,q;
if(GEN){
cin>>n>>q;
cout<<n<<endl;
}
else cin>>n;
lld h[n];
lld a[n];
lld b[n];
for(int i=0;i<n;i++){
if(GEN){
h[i]=rand()%1000000;
a[i]=rand()%n+1;
b[i]=rand()%n+1;
if(a[i]>b[i])swap(a[i],b[i]);
cout<<h[i]<<" "<<a[i]<<" "<<b[i]<<endl;
}
else{
cin>>h[i]>>a[i]>>b[i];
}
}
if(GEN)cout<<q<<endl;
else cin>>q;
vector<lld> answers;
for(int i=0;i<q;i++){
int l,r;
if(GEN){
l=rand()%n;
r=rand()%n;
if(l>r)swap(l,r);
cout<<l<<" "<<r<<endl;
}else cin>>l>>r;
lld ans=-1;
for(int i=l;i<=r;i++){
for(int j=l+1;j<=r;j++){
if(j-i>=a[i] && j-i>=a[j] && j-i<=b[i] && j-i<=b[j]){
ans=max(ans,h[i]-h[j]);
ans=max(ans,h[j]-h[i]);
}
}
}
answers.push_back(ans);
}
for(int i=0;i<q;i++){
cout<<answers[i]<<endl;
}
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... |