| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 929091 | Karoot | Rabbit Carrot (LMIO19_triusis) | C++17 | 94 ms | 16864 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.
#include <iostream>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
ll linf = 1e15+1;
inline void scoobydoobydoo(){
ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main(){
scoobydoobydoo();
ll n, M; cin >> n >> M;
vector<ll> v(n);
vector<ll> filtered;
for (int i = 0; i < n; i++){
cin >> v[i];
if (v[i] <= M*(i+1))filtered.push_back(-v[i]+M*(i+1));
}
set<pair<ll, ll> > s; //value, dp
ll dp[200001];
if (filtered.size() == 0){
cout << n << endl;
return 0;
}
dp[0] = 1;
s.insert({0, 0});
s.insert({filtered[0], 1});
for (int i = 1; i < filtered.size(); i++){
auto it = s.upper_bound({filtered[i], 10000000});
it--;
dp[i] = (*it).second + 1;
if ((*it).first == filtered[i])s.erase(it);
s.insert({filtered[i], dp[i]});
while (true){
auto itr = s.find({filtered[i], dp[i]});
itr++;
if (itr == s.end())break;
if ((*itr).second > dp[i])break;
s.erase(itr);
}
}
cout << n - (*s.rbegin()).second << endl;
return 0;
}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... | ||||
