/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author win11905
*/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define long long long
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
const int N = 505;
class walking {
private:
int n, l;
int dp[N];
vector<pii> vec;
bool check(int a, int b) {
if(vec[a].x >= vec[b].x) return false;
return l * vec[b].y + vec[a].x * vec[a].y * vec[b].y > l * vec[a].y + vec[b].x * vec[b].y * vec[a].y;
}
public:
void solve(istream& cin, ostream& cout) {
cin >> l >> n;
for(int i = 0, a, b; i < n; ++i) cin >> a >> b, vec.emplace_back(a, b);
sort(all(vec));
for(int i = n-1; ~i; --i) {
dp[i] = 1;
for(int j = i+1; j < n; ++j) if(check(i, j)) dp[i] = max(dp[i], dp[j] + 1);
}
cout << *max_element(dp, dp+n);
}
};
class Solver {
public:
void solve(std::istream& in, std::ostream& out) {
walking *obj = new walking();
obj->solve(in, out);
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
Solver solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
solver.solve(in, out);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
616 KB |
Output is correct |
4 |
Correct |
2 ms |
616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
616 KB |
Output is correct |
2 |
Correct |
2 ms |
616 KB |
Output is correct |
3 |
Correct |
2 ms |
676 KB |
Output is correct |
4 |
Correct |
2 ms |
784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
876 KB |
Output is correct |
2 |
Correct |
2 ms |
876 KB |
Output is correct |
3 |
Correct |
2 ms |
876 KB |
Output is correct |
4 |
Correct |
2 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1004 KB |
Output is correct |
2 |
Correct |
2 ms |
1004 KB |
Output is correct |
3 |
Correct |
3 ms |
1004 KB |
Output is correct |
4 |
Correct |
3 ms |
1004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1004 KB |
Output is correct |
2 |
Correct |
3 ms |
1004 KB |
Output is correct |
3 |
Correct |
3 ms |
1008 KB |
Output is correct |
4 |
Correct |
2 ms |
1012 KB |
Output is correct |