Submission #1042912

# Submission time Handle Problem Language Result Execution time Memory
1042912 2024-08-03T14:38:39 Z VMaksimoski008 Kas (COCI17_kas) C++17
0 / 100
196 ms 352596 KB
#include <iostream>
using namespace std;

const int M = 1e5;

int dp[505][2*M+5], v[505], n, S;

int main() {
    cin >> n;

    for(int i=1; i<=n; i++) cin >> v[i], S += v[i];
    // for(int j=0; j<=2*M; j++) dp[0][j] = -1e9;
    dp[0][M] = 0;

    for(int i=1; i<=n; i++) {
        for(int j=0; j<=2*M; j++) {
            dp[i][j] = dp[i-1][j];
            if(j + v[i] <= 2 * M) dp[i][j] = max(dp[i][j], dp[i-1][j+v[i]] + v[i]);
            if(j - v[i] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-v[i]] + v[i]);
        }
    }

    cout << S - dp[n][M] / 2 << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 10588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 27736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 35676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 156756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 235056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 352596 KB Output isn't correct
2 Halted 0 ms 0 KB -