# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
714361 | pashka | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 1087 ms | 852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
int M = 30001;
vector<int> d(2 * M, INT_MAX);
d[M] = 0;
for (int i = 0; i < n; i++) {
vector<int> dd(2 * M, INT_MAX);
for (int j = 0; j < 2 * M; j++) {
if (d[j] == INT_MAX) continue;
// cout << i << " " << j << " " << d[j] << "\n";
int x = a[i] - b[i];
if ((j - M) < 0) {
int y = x + (j - M);
dd[y + M] = min(dd[y + M], d[j] + abs(j - M));
} else {
for (int k = 0; k <= (j - M); k++) {
int y = x + k;
dd[y + M] = min(dd[y + M], d[j] + k);
}
}
}
d = dd;
}
int res = INT_MAX;
for (int i = M; i < d.size(); i++) {
res = min(res, d[i]);
}
cout << res << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |