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>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ld long double
#define nl endl
#define tb '\t'
#define sp ' '
#define sqr(x) (x)*(x)
#define arr3 array<ll, 3>
using namespace std;
const ll MX=200005, MOD=1000000007, BLOCK=160, INF=2e9+7, LG=62;
const ll INFF=1000000000000000007;
const ld ERR=1e-6, pi=3.14159265358979323846;
int N, K, A[MX], top[2][MX], cnt[2][MX], ans;
vector<int> LIS;
int main(){
fastio;
cin >> N >> K;
for(int i=1; i<=N; i++){
cin >> A[i];
}
for(int i=1; i<=N; i++){
int tmp=A[i];
if(LIS.empty() || LIS.back()<tmp)
LIS.pb(tmp);
else
LIS[upper_bound(all(LIS), tmp)-LIS.begin()]=tmp;
top[0][i]=LIS.back();
cnt[0][i]=LIS.size();
}
LIS.clear();
for(int i=N; i>0; i--){
int tmp=-A[i];
if(LIS.empty() || LIS.back()<tmp)
LIS.pb(tmp);
else
LIS[upper_bound(all(LIS), tmp)-LIS.begin()]=tmp;
top[1][i]=-LIS.back();
cnt[1][i]=LIS.size();
}
ans=cnt[0][N];
assert(cnt[0][N]==LIS.size());
cout << ans << nl;
}
Compilation message (stderr)
In file included from /usr/include/c++/10/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
from glo.cpp:1:
glo.cpp: In function 'int main()':
glo.cpp:54:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | assert(cnt[0][N]==LIS.size());
| ~~~~~~~~~^~~~~~~~~~~~
# | 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... |