제출 #1265765

#제출 시각아이디문제언어결과실행 시간메모리
1265765canhnam357Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
73 ms14404 KiB
// source problem : #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define int long long #define lb lower_bound #define ub upper_bound #define MASK(i) (1LL << (i)) void ckmax(int& f, int s) { f = (f > s ? f : s); } void ckmin(int& f, int s) { f = (f < s ? f : s); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] -= i * m; if (a[i] <= 0) a[i] = -a[i]; else a[i] = -1; } set<pair<int, int>> st; for (int i = 1; i <= n; i++) { if (a[i] < 0) continue; auto it = st.lb(make_pair(a[i], i)); if (it != st.end()) st.erase(it); st.insert({a[i], i}); } cout << n - st.size(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...