Submission #1100381

# Submission time Handle Problem Language Result Execution time Memory
1100381 2024-10-13T16:25:36 Z codexistent Kas (COCI17_kas) C++14
100 / 100
288 ms 394596 KB
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define MAXN 505
#define MAXS 200005
#define FOR(i, a, b) for(ll i = a; i <= b; i++)

ll n, dp[MAXN][MAXS], s = 0;

int main(){
    cin >> n;
    FOR(i, 0, MAXN - 5) FOR(j, 0, MAXS - 5) dp[i][j] = MAXS;

    dp[0][100000] = 0;
    FOR(i, 1, n){
        int x; cin >> x;
        s += x;
        FOR(j, x, 200000 - x){
            dp[i][j - x] = min(dp[i][j - x], dp[i - 1][j]);
            dp[i][j + x] = min(dp[i][j + x], dp[i - 1][j]);
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + x);
        }
    } 

    cout << ((s - dp[n][100000]) / 2 + dp[n][100000]) << endl;
}

# Verdict Execution time Memory Grader output
1 Correct 125 ms 392520 KB Output is correct
2 Correct 90 ms 392520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 392612 KB Output is correct
2 Correct 95 ms 392608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 392520 KB Output is correct
2 Correct 102 ms 392520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 392520 KB Output is correct
2 Correct 106 ms 392600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 392620 KB Output is correct
2 Correct 138 ms 392460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 392520 KB Output is correct
2 Correct 125 ms 392396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 144 ms 392520 KB Output is correct
2 Correct 148 ms 392600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 394408 KB Output is correct
2 Correct 200 ms 392520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 219 ms 392456 KB Output is correct
2 Correct 262 ms 394596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 257 ms 392520 KB Output is correct
2 Correct 288 ms 392780 KB Output is correct