Submission #1140836

#TimeUsernameProblemLanguageResultExecution timeMemory
1140836ndanRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define file "test" #define forr(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define ford(i, b, a) for (int i = (b), _a = (a); i >= _a; --i) #define forf(i, a, b) for (int i = (a), _b = (b); i < _b; ++i) #define rep(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define pb push_back #define mp make_pair #define fi first #define se second #define all(x) x.begin(), x.end() #define MASK(i) (1LL << (i)) const int maxn = 2e5 + 10; const int MOD = 1e9 + 7; const ll inf = 1e18; const int oo = 1e9 + 7; const float eps = 1e-6; int n, m, ans = 0, p[maxn], idx = 0; ll a[maxn], dp[maxn]; vector<ll> v; int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifndef ONLINE_JUDGE // freopen(file".inp", "r", stdin); // freopen(file".out", "w", stdout); #endif cin >> n >> m; forr(i, 1, n) // Chỉ số mảng bắt đầu từ 1 cin >> p[i]; dp[1] = 0; forr(i, 2, n + 1) dp[i] = inf; forr(i, 1, n) if (i * m >= p[i]) a[++idx] = m * i - p[i]; forr(i, 1, idx) { int pos = upper_bound(dp + 1, dp + n + 1, a[i]) - dp; dp[pos] = a[i]; ans = max(ans, pos); } cout << n - ans; return 0; } /* /⌒ ヽ    /° ω° \  _ノ ヽ ノ \_ ‘/ / ⌒Y⌒ Y  ヽ (  (三ヽ人  /  | |  ノ⌒\  ̄ ̄ヽ ノ ヽ___>、__/    |( 王 ノ〈    /ミ`ー―彡ヽ   / ヽ/  |. */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...