# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347877 | 2021-01-13T17:24:41 Z | oleksg | Rabbit Carrot (LMIO19_triusis) | C++11 | 3 ms | 364 KB |
#pragma GCC optimize("O2") #include <fstream> #include <string> #include <iostream> #include <bitset> #include <math.h> #include <string> #include <algorithm> #include <assert.h> #include<bits/stdc++.h> #include <vector> #include <queue> #include<stdio.h> #include<ctype.h> #define ll long long using namespace std; ll n, m; ll arr[200002]; vector<ll> dp; int main(){ cin >> n >> m; arr[0] = 0; for (int x = 0; x < n; x++){ cin >> arr[x + 1]; } reverse(arr, arr + (n + 1)); ll answer = n; for (int x = 0; x <= n; x++){ int pos = upper_bound(dp.begin(), dp.end(), arr[x] + m) - dp.begin(); if (pos == 0){ if (pos == dp.size()){ dp.push_back(arr[x]); } else{ dp[pos] = arr[x]; } } else{ if (dp[pos - 1] >= arr[x] - m){ if (pos == dp.size()){ dp.push_back(arr[x]); } else{ dp[pos] = arr[x]; } } } if (upper_bound(dp.begin(), dp.end(), m) != dp.begin()){ pos = upper_bound(dp.begin(), dp.end(), m) - dp.begin(); answer = min(answer, n - (pos + 1)); } } cout << answer << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |