# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
702120 | ifateen | Rabbit Carrot (LMIO19_triusis) | C++14 | 0 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef ONLINE_JUDGE
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#else
#include <bits/stdc++.h>
#endif
using namespace std;
#define int long long
#define double long double
#define vec vector
#define vi vec<int>
#define pii pair<int,int>
#define vpi vec<pii>
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define pq priority_queue
#define all(v) v.begin(), v.end()
signed main() {
int n,t;
cin >> n >> t;
vi v(n+1,0);
for (int i = 1; i <= n; i++) cin >> v[i];
int k = 1;
vi dp(n+1,-1e18);
int u = 0;
for (int i = 1; i <= n; i++) {
if (v[i] - v[i - 1] > t) dp[i] = k++;
if (i == 1 and v[i] > t) u++;
}
vi liss;
for (int i = 0; i < dp.size(); i++) {
int pos = lower_bound(liss.begin(), liss.end(), dp[i]) - liss.begin();
if (pos == liss.size()) {
liss.push_back(i);
} else {
liss[pos] = i;
}
}
cout << liss.size()+u << endl;
}
Compilation message (stderr)
# | 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... |