Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{
int N;
cin>>N;
vector<int>A;
vector<int>B;
int cntA=0, cntB=0;
for(int i=0; i<N; i++)
{
int x;
cin>>x;
A.push_back(x);
}
for(int i=0; i<N; i++)
{
int x;
cin>>x;
B.push_back(x);
}
for(int i=1; i<N-1; i++)
{
if(A[i]>B[i+1] && A[i]>B[i-1])
{
cntA++;
}
else if(B[i]>A[i+1] && B[i]>A[i-1])
{
cntB++;
}
}
if(cntA==N-2) cout<<"Yes"<<endl;
else if(cntB==N-2) cout<<"Yes"<<endl;
else if(N==1) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
A.clear();
B.clear();
}
}
Information
- Submit By
- Type
- Pretest
- Problem
- P1193 C. Roy and Peak Array
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-06-13 17:04:53
- Judged At
- 2025-06-13 17:04:53
- Judged By
- Score
- 10
- Total Time
- 1ms
- Peak Memory
- 540.0 KiB