-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path382_Internet_en_el_metro.cpp
54 lines (46 loc) · 1.08 KB
/
382_Internet_en_el_metro.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
// Usuario de Acepta el reto: jjjjjjjp022
#include <iostream>
#include <deque>
using namespace std;
typedef long long int lli;
int main()
{
int n;
cin >> n;
while(n--)
{
lli length, amount;
cin >> length >> amount;
deque <pair<lli, lli>> v;
lli point, rad;
while(amount--)
{
cin >> point >> rad;
while(!v.empty() && v.back().first >= point-rad)
{
v.pop_back();
}
if(v.empty() || v.back().second < point+rad)
v.push_back({point-rad, point+rad});
}
lli prev;
bool ok = true;
if(v.front().first > 0)
ok = false;
prev = v.front().second;
v.pop_front();
while(ok && !v.empty())
{
if(prev < v.front().first)
ok = false;
prev = v.front().second;
v.pop_front();
}
if(prev < length)
ok = false;
if(ok)
cout << "SI\n";
else
cout << "NO\n";
}
}