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>
typedef long long ll;
struct Point {
ll x, y;
void transform() {
ll u = y + x, v = y - x;
x = u, y = v;
}
};
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n, m;
std::cin >> n >> m;
std::vector<Point> pts(m + 1);
std::vector<ll> t(m + 1), a(m + 1);
for (ll i = 1; i <= m; ++i) {
std::cin >> t[i];
pts[i].x = t[i];
}
for (ll i = 1; i <= m; ++i) {
std::cin >> a[i];
pts[i].y = a[i];
}
for (auto &i : pts) {
i.transform();
}
std::sort(pts.begin(), pts.end(), [](Point a, Point b) {
if (a.x != b.x) {
return a.x < b.x;
}
return a.y > b.y;
});
std::vector<ll> dp;
for (ll i = 1; i <= m; ++i) {
auto it = std::lower_bound(dp.begin(), dp.end(), pts[i].y);
if (it == dp.end()) {
dp.push_back(pts[i].y);
} else {
dp[it - dp.begin()] = pts[i].y;
}
}
std::cout << dp.size() << '\n';
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |