Submission #1088622

#TimeUsernameProblemLanguageResultExecution timeMemory
1088622mtshastaJob Scheduling (CEOI12_jobs)C++17
0 / 100
1069 ms2264 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; void solve() { int n, m; cin >> n >> m; vector<int> a(n + 1), b, dist; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) { if (m * i >= a[i]) b.push_back(m * i - a[i]); } if (b.empty()) { cout << n << '\n'; return; } int sz = b.size(); dist.resize(sz); for (int i = 0; i < sz; ++i) { dist[i] = 1; for (int j = 0; j < i; ++j) { if (b[j] <= b[i]) dist[i] = max(dist[i], dist[j] + 1); } } cout << n - *max_element(dist.begin(), dist.end()) << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...