# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
714361 | 2023-03-24T09:37:58 Z | pashka | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 1000 ms | 852 KB |
#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; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 744 KB | Output is correct |
2 | Correct | 211 ms | 744 KB | Output is correct |
3 | Incorrect | 257 ms | 852 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 744 KB | Output is correct |
2 | Correct | 211 ms | 744 KB | Output is correct |
3 | Incorrect | 257 ms | 852 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 744 KB | Output is correct |
2 | Correct | 211 ms | 744 KB | Output is correct |
3 | Correct | 1 ms | 744 KB | Output is correct |
4 | Correct | 992 ms | 744 KB | Output is correct |
5 | Execution timed out | 1087 ms | 728 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 744 KB | Output is correct |
2 | Correct | 211 ms | 744 KB | Output is correct |
3 | Incorrect | 257 ms | 852 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 744 KB | Output is correct |
2 | Correct | 211 ms | 744 KB | Output is correct |
3 | Incorrect | 257 ms | 852 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |