답안 #714400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714400 2023-03-24T10:17:23 Z pashka Potatoes and fertilizers (LMIO19_bulves) C++14
20 / 100
985 ms 262144 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];
    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;
    }
    cout << d[na] << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Runtime error 361 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Runtime error 361 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 105 ms 524 KB Output is correct
5 Correct 925 ms 820 KB Output is correct
6 Correct 719 ms 832 KB Output is correct
7 Correct 258 ms 616 KB Output is correct
8 Correct 80 ms 496 KB Output is correct
9 Correct 985 ms 724 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Runtime error 361 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Runtime error 361 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -