# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
285509 | arnold518 | Arcade (NOI20_arcade) | C++14 | 1 ms | 384 KiB |
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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXM = 5e5;
const int INF = 1e9;
int N, M, T[MAXM+10], A[MAXM+10], C[MAXM+10];
pii B[MAXM+10];
int tree[MAXM+10];
void update(int i, int k) { i=M-i+1; for(; i<=M; i+=(i&-i)) tree[i]=max(tree[i], k); }
int query(int i) { i=M-i+1; int ret=0; for(; i>0; i-=(i&-i)) ret=max(ret, tree[i]); return ret; }
int dp[MAXM+10];
int main()
{
scanf("%d%d", &N, &M);
for(int i=1; i<=M; i++) scanf("%d", &T[i]);
for(int i=1; i<=M; i++) scanf("%d", &A[i]);
for(int i=1; i<=M; i++)
{
int x=A[i]-T[i], y=A[i]+T[i];
B[i]={x, y};
}
sort(B+1, B+M+1);
vector<int> comp;
for(int i=1; i<=M; i++) comp.push_back(B[i].second);
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());
for(int i=1; i<=M; i++) C[i]=lower_bound(comp.begin(), comp.end(), B[i].second)-comp.begin();
int ans=0;
for(int i=1; i<=M; i++)
{
dp[i]=query(C[i]+1)+1;
ans=max(ans, dp[i]);
update(C[i], dp[i]);
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | 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... |