Submission #475535

#TimeUsernameProblemLanguageResultExecution timeMemory
475535nohaxjustsofloRabbit Carrot (LMIO19_triusis)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set; const int mxN = 5e5+5; const int mod = 998244353; const int mxlogN = 20; const int mxK = 26; int a[mxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; map<int, int> mp; mp[0] = 0; int incall = 0; int bonus = 0; for(int i = 0; i < n; i++) { cin >> a[i]; int x = a[i]; auto it = mp.lower_bound(x-m-incall); if(it != mp.end()) { mp[x-m-incall] = it->second-1; auto jt = mp.lower_bound(x-incall); auto pre = prev(jt); while(jt != mp.begin() && pre->second >= jt->second) { mp.erase(pre); pre = prev(it); } } incall += m; bonus++; } cout << mp.begin()->second+bonus << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...