This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
const int maxn = 505;
int l, n;
struct DATA {
int t, v;
double x;
};
DATA p[maxn];
int dp[maxn];
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> l >> n;
for(int i = 1; i <= n; ++i){
cin >> p[i].t >> p[i].v;
p[i].x = (double)(l / (double)p[i].v) + (double)p[i].t;
}
sort(p + 1, p + n + 1, [&](DATA x, DATA y){
if(x.t == y.t)return x.x > y.x;
else return x.t < y.t;
});
int ans = 0;
for(int i = 1; i <= n; ++i){
dp[i] = 1;
for(int j = 1; j < i; ++j){
if(p[j].x > p[i].x){
dp[i] = max(dp[i], dp[j] + 1);
}
}
ans = max(ans, dp[i]);
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |