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>
using namespace std;
#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;
#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 500005
int n, m;
ii ta[MAXN], xy[MAXN];
vi lis;
int main() {
scanf("%d%d", &n, &m);
REP (i, 0, m) {
scanf("%d", &ta[i].FI);
}
REP (i, 0, m) {
scanf("%d", &ta[i].SE);
}
REP (i, 0, m) {
xy[i] = MP(ta[i].SE - ta[i].FI, ta[i].FI + ta[i].SE);
}
sort(xy, xy + n);
REP (i, 0, m) {
int upper = upper_bound(ALL(lis), xy[i].SE) - lis.begin();
if (upper == lis.size()) {
lis.pb(xy[i].SE);
} else {
lis[upper] = xy[i].SE;
}
}
printf("%d\n", (int) lis.size());
return 0;
}
Compilation message (stderr)
Arcade.cpp: In function 'int main()':
Arcade.cpp:45:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if (upper == lis.size()) {
| ~~~~~~^~~~~~~~~~~~~
Arcade.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
32 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
Arcade.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
34 | scanf("%d", &ta[i].FI);
| ~~~~~^~~~~~~~~~~~~~~~~
Arcade.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
37 | scanf("%d", &ta[i].SE);
| ~~~~~^~~~~~~~~~~~~~~~~
# | 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... |