-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTSP.cpp
42 lines (42 loc) · 909 Bytes
/
TSP.cpp
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
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define speed() \
ios::sync_with_stdio(false); \
cin.tie(0)
#define piss(name) \
speed(); \
freopen(#name "in.txt","r",stdin); \
freopen(#name "out.txt","w",stdout)
#define ll long long
#define umap std::unordered_map
#define ummap std::unordered_multimap
#define uset std::unordered_set
#define umset std::unordered_multiset
#define mmap std::multimap
#define mset std::multiset
int main()
{
piss(tsp);
int n;cin>>n;
vector<int>l;vector<int>r;
for (int i=0;i<n;i++){
int iv;cin>>iv;
l.push_back(iv);
}
for (int i=0;i<n;i++){
int iv;cin>>iv;
r.push_back(iv);
}
int reqnext=l[0];
for (int i=1;i<n;i++){
if (reqnext<=l[i])
reqnext=l[i];
if (reqnext>r[i]){
cout<<"NO\n";
exit(0);
}
}
cout<<"YES\n";
}