Submission #959995

#TimeUsernameProblemLanguageResultExecution timeMemory
959995CookieArcade (NOI20_arcade)C++14
100 / 100
276 ms18380 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; #define sz(a) (int)a.size() #define ALL(v) v.begin(), v.end() #define ALLR(v) v.rbegin(), v.rend() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> #define mpp make_pair const ld PI = 3.14159265359, prec = 1e-9;; //using u128 = __uint128_t; //const int x[4] = {1, 0, -1, 0}; //const int y[4] = {0, -1, 0, 1}; const ll mod = 1e9 + 69, pr = 31; const int mxn = 5e5 + 5, mxq = 1e5 + 5, sq = 300, mxv = 5e4 + 1; //const int base = (1 <<18); const ll inf = 1e18 + 5, neg = -69420, inf2 = 1e14; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); // have fun! // <3; int n, m; vt<int>comp; int bit[mxn + 1], dp[mxn + 1]; pii p[mxn + 1]; int find(int x){ return(lower_bound(ALL(comp), x) - comp.begin() + 1); } void upd(int p, int v){ while(p <= sz(comp)){ bit[p] = max(bit[p], v); p += p & (-p); } } int get(int p){ int ans = 0; while(p){ ans = max(ans, bit[p]); p -= p & (-p); } return(ans); } void solve(){ cin >> n >> m; for(int i = 1; i <= m; i++)cin >> p[i].fi; for(int i = 1; i <= m; i++)cin >> p[i].se; for(int i = 1; i <= m; i++){ p[i] = mpp(p[i].fi + p[i].se, p[i].fi - p[i].se); comp.pb(-p[i].se); } sort(ALL(comp)); sort(p + 1, p + m + 1); for(int i = 1; i <= m; i++){ dp[i] = get(find(-p[i].se) - 1) + 1; upd(find(-p[i].se), dp[i]); } cout << *max_element(dp + 1, dp + m + 1); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("netw.inp", "r", stdin); //freopen("netw.out", "w", stdout); int ttt; ttt = 1; while(ttt--){ solve(); } return(0); } /* 1 5 7 2 1 1 1 3 1 2 2 2 3 4 2 4 2 4 2 1 5 5 3 5 2 5 3 2 7 3 3 1 1 1 1 1 2 2 1 3 3 3 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...