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>
// #include <ext/rope>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
using namespace std;
#define NFS cin.tie(0)->sync_with_stdio(0);
#define io freopen("mal.in", "r", stdin);\
freopen("mal.out", "w", stdout);
#define all(v) v.begin(),v.end()
#define drop(v) cout<<(v)<<endl;return;
#define print(arr) for(auto v:arr){cout<<v<<" ";}cout<<endl;
#define str string
#define pii pair<int,int>
#define umap unordered_map
#define int long long int
#define ins insert
#define mp make_pair
#define endl "\n"
#define sz(arr) arr.size()
#define to_str(n) to_string(n)
#define birs(n) __builtin_popcount(n)
#define rep(ij,start,finish) for(int ij=start;ij<finish;ij++)
template<typename T> T in() {T v;cin>>v;return v;}
#define in(type) in<type>()
template<class Elem>
struct vec : public std::vector<Elem>{
using std::vector<Elem>::vector;
auto min(){ return min_element(this->begin(), this->end()); }
auto max(){ return max_element(this->begin(), this->end()); }
int sum(){ return accumulate(this->begin(),this->end(),0LL); }
void pb(Elem args){ this->push_back(args); }
Elem pop(){ Elem x = move(this->back()); this->pop_back(); return x; }
int ln(){ return this->size(); }
Elem& operator[](size_t idx) {
if(this->empty()){
cout<<"Hata: vec<...> bombos! "<<"=> ["<<idx<<"]"<<endl;
static Elem tmp;return tmp;
}
else if(idx >= this->size()){
cout<<"Hata: index fazla buyuk! "<<"=> ["<<idx<<"]"<<endl;
static Elem tmp;return tmp;
}
return std::vector<Elem>::operator[](idx);
}
};
/*>>*/
template<class IStr, class U, class T>
IStr& operator>>(IStr& is, pair<U,T>& p) { return is >> p.first >> p.second; }
template<class IStr, class U, class T>
IStr& operator>>(IStr& is, vector<pair<U,T>>& v) { for (auto& x : v) is >> x; return is; }
template<class IStr, class T>
IStr& operator>>(IStr& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
/*<<*/
template<class OStr, class T>
OStr& operator<<(OStr& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << ' '; os << v[i]; } return os; }
template<class OStr, class T>
OStr& operator<<(OStr& os, const set<T>& arr) { for (auto v:arr) { os << v <<' '; } return os; }
template<class U, class T>
std::ostream& operator<<(std::ostream& os, const std::pair<U,T>& p) { os<<p.first<<" "<<p.second; return os; }
template<typename... T> void lan(const T&... args){((cout<<(args)<<" "),...);cout<<endl;}
int binpow(int a,int b,int mod){
if(b==0) return 1;
int half = binpow(a,b>>1,mod),res = (half*half)%mod;
if(b&1) res=(res*a)%mod;
return res;
}
// template <class T>
// using sat =
// tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // include pb_ds
//
int T=1;
const int mod = 998244353, sze = 3e5+5 ,inf=1000000000000000000LL;
void lq(){
int n;
cin>>n;
map<int,int> idx;
vec<int> arr(n);
rep(i,0,n){
cin>>arr[i];
idx[arr[i]]=i;
}
vec<int> lst;
vec<int> brr(n);
rep(i,0,n){
lst.pb(idx[in(int)]);
}
vec<int> lis;
for(auto v:lst){
if(lis.empty() || v>=lis.back()){
lis.pb(v);
}
else{
auto it = lower_bound(all(lis),v);
*it=v;
}
}
drop(sz(lis));
}
signed main(){
NFS;
// io;
// cin>>T;
while(T--){
lq();
}
return 0;
}
# | 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... |