Submission #6479283


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = (int) (1e9 + 7);

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

template< typename T >
size_t longest_increasing_subsequence(const vector< T > &a, bool strict) {
  vector< int > lis;
  for(auto &p : a) {
    typename vector< T >::iterator it;
    if(strict) it = lower_bound(begin(lis), end(lis), p);
    else it = upper_bound(begin(lis), end(lis), p);
    if(end(lis) == it) lis.emplace_back(p);
    else *it = p;
  }
  return lis.size();
}


int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  reverse(begin(A), end(A));
  cout << longest_increasing_subsequence(A, false) << endl;
}

Submission Info

Submission Time
Task E - Sequence Decomposing
User ei13333
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2666 Byte
Status
Exec Time 15 ms
Memory 1276 KB

Judge Result

Set Name Score / Max Score Test Cases
All 500 / 500 all_same, killer_01, killer_02, killer_03, killer_04, killer_05, many_dup_01, many_dup_02, many_dup_03, many_dup_04, many_dup_05, many_dup_06, many_dup_07, many_dup_08, many_dup_09, many_dup_10, many_dup_11, many_dup_12, rand_max_01, rand_max_02, rand_max_03, rand_max_04, rand_max_05, rand_max_06, rand_max_07, rand_max_08, rand_max_09, rand_max_10, rand_max_11, sample_01, sample_02, sorted_ascending, sorted_descending, unique_perm_01, unique_perm_02
Sample 0 / 0 sample_01, sample_02
Case Name Status Exec Time Memory
all_same 15 ms 1276 KB
killer_01 13 ms 1276 KB
killer_02 12 ms 1276 KB
killer_03 13 ms 1276 KB
killer_04 13 ms 1276 KB
killer_05 13 ms 1276 KB
many_dup_01 14 ms 640 KB
many_dup_02 15 ms 640 KB
many_dup_03 14 ms 640 KB
many_dup_04 15 ms 640 KB
many_dup_05 15 ms 768 KB
many_dup_06 14 ms 640 KB
many_dup_07 15 ms 896 KB
many_dup_08 15 ms 896 KB
many_dup_09 13 ms 896 KB
many_dup_10 14 ms 1024 KB
many_dup_11 14 ms 1024 KB
many_dup_12 13 ms 896 KB
rand_max_01 14 ms 640 KB
rand_max_02 14 ms 640 KB
rand_max_03 14 ms 640 KB
rand_max_04 14 ms 640 KB
rand_max_05 14 ms 640 KB
rand_max_06 14 ms 640 KB
rand_max_07 14 ms 640 KB
rand_max_08 14 ms 640 KB
rand_max_09 14 ms 640 KB
rand_max_10 15 ms 640 KB
rand_max_11 14 ms 640 KB
sample_01 1 ms 256 KB
sample_02 1 ms 256 KB
sorted_ascending 9 ms 640 KB
sorted_descending 11 ms 1276 KB
unique_perm_01 12 ms 640 KB
unique_perm_02 12 ms 640 KB