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>
#define int int64_t
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ar = array<int, 2>;
const int64_t INF = 1ll << 30;
const int N = 2e5 + 5;
ar a[N + 5];
int n, dp[N];
bool cmp(int i, int j) {
return a[i][0] * a[j][1] < a[j][0] * a[i][1];
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int L;
cin >> L >> n;
FOR(i, 0, n) {
cin >> a[i][0] >> a[i][1];
}
sort(a, a + n, [&](const auto A, const auto B) {return A[0] > B[0];});
FOR(i, 0, n) {
a[i][0] *= a[i][1];
a[i][0] += L;
}
a[N] = {INF, 1};
a[N + 1] = {-INF, 1};
fill(dp, dp + N, N);
dp[0] = N + 1;
FOR(i, 0, n) {
int x = lower_bound(dp, dp + N, i, cmp) - dp;
dp[x] = i;
}
int x = 0;
while (dp[x] != N) ++x;
cout << --x << '\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... |