-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheating_Time.cpp
More file actions
38 lines (38 loc) · 914 Bytes
/
cheating_Time.cpp
File metadata and controls
38 lines (38 loc) · 914 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
#include<iostream>
#include<vector>
#include<algorithm>
// #define int long long
using namespace std;
int32_t main(){
int t;
cin >> t;
while(t--)
{
int n, k, f;
cin >> n >> k >> f;
vector<pair<int, int>> inv;
while(n--){
int a, b;
cin >> a >> b;
inv.push_back({a, b});
}
int totTime = 0;
sort(inv.begin(), inv.end());
int prev =0;
for(int i = 0; i < inv.size(); i++){
totTime += max(0, (inv[i].first - prev));
prev = max(prev, inv[i].second);
}
totTime += max(0, f - prev);
if(totTime >= k)
{
// cout << totTime << "\n";
cout << "YES" << "\n";
}
else{
// cout << totTime << "\n";
cout << "NO" << "\n";
}
}
return 0;
}