-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsegment_naive.cpp
80 lines (72 loc) · 1.4 KB
/
segment_naive.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include<iostream>
#include<ctime>
using namespace std;
const long long SIZE = 100000;
long long n,q,cnt = 0;
class Segment
{
private:
long long left;
long long right;
public:
Segment(long long left = 0, long long right = 0)
{
this -> left = left;
this -> right = right;
}
void Set(long long left, long long right)
{
this -> left = left;
this -> right = right;
}
long long GetLeft()
{
return this -> left;
}
long long GetRight()
{
return this -> right;
}
bool Check(long long poi_nt)
{
if(this->left<= poi_nt && this -> right >= poi_nt)
return 1;
return 0;
}
}Segments[SIZE];
void Init()
{
cin>>n>>q;
for(long long i = 0; i < n; i++)
{
long long x,y;
cin>>x>>y;
Segments[i].Set(x,y);
}
}
void Solve()
{
for(long long i = 0; i < q; i++)
{
long long poi_nt;
cin>>poi_nt;
for(long long j = 0; j < n; j++)
{
if(Segments[j].Check(poi_nt))
{
cnt++;
}
}
//cout<<cnt<<endl;
cnt = 0;
}
}
int main()
{
time_t a = time(NULL);
Init();
Solve();
time_t b = time(NULL);
cout<<b-a<<endl;
return 0;
}