# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
714400 | pashka | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 985 ms | 262144 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>
#define long long long int
#define DEBUG
using namespace std;
// @author: pashka
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
vector<int> aa, bb;
for (int i = 0; i < n; i++) {
for (int j = 0; j < a[i]; j++) aa.push_back(i);
for (int j = 0; j < b[i]; j++) bb.push_back(i);
}
int na = aa.size();
int nb = bb.size();
vector<int> d(na + 1);
for (int i = 0; i < nb; i++) {
vector<int> dd(na + 1, INT_MAX);
for (int j = i; j < na; j++) {
dd[j + 1] = min(dd[j], d[j] + abs(aa[j] - bb[i]));
}
d = dd;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |