Submission #1013088

#TimeUsernameProblemLanguageResultExecution timeMemory
1013088TrinhKhanhDungArcade (NOI20_arcade)C++14
100 / 100
151 ms16700 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define sz(x) (int)x.size() #define ALL(v) v.begin(),v.end() #define MASK(k) (1LL << (k)) #define BIT(x, i) (((x) >> (i)) & 1) #define oo (ll)1e18 #define INF (ll)1e9 #define MOD (ll)(998244353) using namespace std; template<class T1, class T2> bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;} template<class T1, class T2> bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;} template<class T1, class T2> void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;} template<class T1, class T2> void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;} template<class T> void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());} const int MAX = 5e5 + 10; int N, M; pair<int, int> a[MAX]; int x[MAX], y[MAX]; void solve(){ cin >> N >> M; for(int i=1; i<=M; i++){ cin >> x[i]; } for(int i=1; i<=M; i++){ cin >> y[i]; } for(int i=1; i<=M; i++){ a[i] = make_pair(x[i] - y[i], x[i] + y[i]); } sort(a + 1, a + M + 1); vector<int> lst; for(int i=1; i<=M; i++){ int p = lower_bound(ALL(lst), -a[i].se) - lst.begin(); if(p == sz(lst)){ lst.push_back(-a[i].se); } else{ lst[p] = -a[i].se; } } cout << sz(lst) << '\n'; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("split.inp", "r", stdin); // freopen("split.out", "w", stdout); int tt = 1; // cin >> tt; while(tt--){ solve(); } return 0; }
#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...