Submission #977948

#TimeUsernameProblemLanguageResultExecution timeMemory
977948mohamedsiuRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms2544 KiB
#include<bits/stdc++.h> #define int long long #define pii pair<int,int> #define fi first #define se second using namespace std; using ll = long long; using ld = long double; const int maxn = 3e5 + 5; const int maxN = 1e5; const int mod = 1e9 + 7; const ll inf = 1e18; const int tt = 5e3 + 5; const int base = 31; const int lim = 100; const int BLOCK_SIZE = 340; const int TWO_MOD_INV = 500000004; int dx[] = {0,-1,0,1,-1,1,-1,1}; int dy[] = {-1,0,1,0,-1,1,1,-1}; int n,m; int a[maxn]; int d[maxn]; void Read() { cin >> n >> m; for(int i = 1;i <= n;i++) cin >> a[i]; d[0] = 0; int id = 0; int res = 0; for(int i = 1;i <= n;i++) { int k = upper_bound(d,d + id + 1,a[i]) - d; if(k > id) { if(a[i] - d[id] > m) { res++; a[k] = d[id] + m; } else d[k] = a[i]; } else d[k] = a[i]; id = k; } cout << res; } void Solve() { } void Debug() { } int32_t main() { // freopen("test.in","r",stdin); // freopen("test.out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); int tt; tt = 1; // Prepare(); // cin >> tt; for(int i = 1; i <= tt; i++) { Read(); Solve(); Debug(); } } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...