제출 #839411

#제출 시각아이디문제언어결과실행 시간메모리
839411MathandskiRabbit Carrot (LMIO19_triusis)C++14
100 / 100
62 ms6800 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define is insert #define ll long long #define V vector #define MS multiset #define PL pair<ll, ll> #define F first #define S second #define PQ priority_queue #define f0r(i, begin, end) for (ll i = begin; i < end; i ++) #define For(i, end, begin) for (ll i = end; i > begin; i --) #define all(x) x.begin(), x.end() #define INF 1000000000000000000 #define inf 1000000000 #define MOD 998244353 #define len(x) (ll)x.size() #define fileread(file) ifstream fin; fin.open((string)file + ".in"); ofstream fout; fout.open((string)file + ".out") #define fastio ios_base::sync_with_stdio(0LL); cin.tie(nullptr) template<typename T> istream& operator>>(istream& in, V<T>& a) {for(auto &x : a) in >> x; return in;}; template<typename T> ostream& operator<<(ostream& out, V<T>& a) {for(auto &x : a) out << x << ' '; return out;}; ll N, M; V<ll> heights; int main () { cin >> N >> M; heights.pb(0); f0r (i, 1, N + 1) { ll a; cin >> a; heights.pb(-a + i * M); } V<ll> dp; for (auto num : heights) { ll pos = upper_bound(all(dp), num) - dp.begin(); if (num < 0) continue; else if (dp.empty()) dp.pb(num); else if (pos == len(dp)) dp.pb(num); else { dp[pos] = num; } } cout << N - len(dp) + 1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...