#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef deque<int> dqi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ppf pop_front
#define pf push_front
#define pb push_back
#define fr first
#define sc second
#define all(a) a.begin(), a.end()
#define sr(a) sort(all(a))
#define sz(a) a.size()
#define rep(x, a, b) for(auto x=a;(a<b?x<b:x>b);(a<b?x++:x--))
#define mnto(x,y) x = min(x, (__typeof__(x))y)
#define mxto(x,y) x = max(x, (__typeof__(x))y)
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int l, n;
cin >> l >> n;
vector<pii> tv(n);
rep(i, 0, n) cin >> tv[i].fr >> tv[i].sc;
sr(tv);
vi dp(n, 1);
rep(i, 1, n) {
rep(j, 0, i) {
if ((l + tv[j].fr * tv[j].sc) * tv[i].sc > (l + tv[i].fr * tv[i].sc) * tv[j].sc) {
mxto(dp[i], dp[j] + 1);
}
}
}
cout << *max_element(all(dp));
}
| # | 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... |