#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
void solve() {
int n, l; cin >> l >> n;
vector<pair<double,int>> tin(n), tout(n);
for (int i = 0; i < n; i++) {
int t, v; cin >> t >> v;
tin[i] = {t, i};
tout[i] = {(double)l / v + t, i};
}
sort(tin.begin(), tin.end());
sort(tout.rbegin(), tout.rend());
vector<vector<int>> dp(n + 1, vector<int>(n + 1));
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
dp[i][j] = (tin[i - 1].second == tout[j - 1].second) ? dp[i - 1][j - 1] + 1 : max(dp[i - 1][j], dp[i][j - 1]);
cout << dp[n][n] << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int tc; tc = 1;
for (int t = 1; t <= tc; t++) {
// cout << "Case #" << t << ": ";
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
748 KB |
Output is correct |
2 |
Correct |
1 ms |
876 KB |
Output is correct |
3 |
Correct |
1 ms |
876 KB |
Output is correct |
4 |
Correct |
1 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1388 KB |
Output is correct |
2 |
Correct |
2 ms |
1004 KB |
Output is correct |
3 |
Correct |
2 ms |
1132 KB |
Output is correct |
4 |
Correct |
2 ms |
1132 KB |
Output is correct |