# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088622 | mtshasta | Job Scheduling (CEOI12_jobs) | C++17 | 1069 ms | 2264 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |