-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cow_Jog.cpp
41 lines (40 loc) · 1.03 KB
/
Cow_Jog.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
#pragma GCC optimize("O2")
#include <fstream>
#include <string>
#include <iostream>
#include <bitset>
#include <math.h>
#include <string>
#include <algorithm>
#include<bits/stdc++.h>
#include <vector>
#include <queue>
using namespace std;
long long n, t;
pair<long long, long long> st[100001];
vector<pair<long long, long long>> se;
int main(){
ifstream in("cowjog.in");
ofstream out("cowjog.out");
in >> n >> t;
long long one, two;
for (int x = 0; x < n; x++){
in >> one >> two;
st[x] = make_pair(one, two);
}
for (int x = 0; x < n; x++){
se.push_back({st[x].first, st[x].first + (st[x].second * t)});
}
vector<long long> dp;
sort(se.rbegin(), se.rend());
for (int x = 0; x < n; x++){
int pos = upper_bound(dp.begin(), dp.end(), se[x].second) - dp.begin();
if (pos == dp.size()){
dp.push_back(se[x].second);
}
else{
dp[pos] = se[x].second;
}
}
out << dp.size() << "\n";
}