-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBREAK.cpp
More file actions
executable file
·45 lines (44 loc) · 817 Bytes
/
BREAK.cpp
File metadata and controls
executable file
·45 lines (44 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t, s, n;
cin>>t>>s;
while(t--) {
cin>>n;
vector<int> a(n), b(n);
for(int i=0; i<n; i++)
cin>>a[i];
for(int i=0; i<n; i++)
cin>>b[i];
sort(a.begin(),a.end());
sort(b.begin(), b.end());
bool ans=true;
vector<int> present;
for(int i=0; i<n; i++) {
if(present.empty())
present.push_back(a[i]);
else if(find(present.begin(), present.end(), a[i]) != present.end())
present.push_back(a[i]);
else {
ans=false;
break;
}
if(b[i]>a[i]) {
present.push_back(b[i]);
}
else {
ans=false;
break;
}
}
if(ans)
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
}