제출 #1083452

#제출 시각아이디문제언어결과실행 시간메모리
1083452icyalmondRabbit Carrot (LMIO19_triusis)C++17
100 / 100
29 ms5468 KiB
#include <bits/stdc++.h> #define ii pair <int, int> #define ll long long #define llll pair <ll, ll> #define ld long double #define ull unsigned long long #define el "\n" #define sp " " #define fi first #define se second #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define __lcm(a, b) (a / __gcd(a, b) * b) #define sq(x) (x) * (x) #define sqr(x) sqrtl(x) #define cbr(x) cbrtl(x) #define sz(a) (ll)(a.size()) using namespace std; const ld PI = acos(-1); const int INFI = 1e9 + 7; const ll INFL = 2e18 + 7; int n, pos, ans; ll m, x, a[200005], b[200005]; void Solve() { cin >> n >> m; for (ll i = 1; i <= n; i++) { cin >> x; a[i] = i * m - x; b[i] = INFL; } for (int i = 1; i <= n; i++) { if (a[i] >= 0) { pos = upper_bound(b + 1, b + 1 + n, a[i]) - b; b[pos] = a[i]; ans = max(ans, pos); } } cout << n - ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0); Solve(); return 0; } //coded by icyalmond
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...