# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92438 | 2019-01-02T20:51:30 Z | wolf | Kas (COCI17_kas) | C++14 | 316 ms | 395772 KB |
#include <bits/stdc++.h> using namespace std; using vi = vector<int> ; using ll = long long; #define pb push_back #define inf 0x3f3f3f3f #define all(v) (v).begin() , (v).end() #define ones(n) __builtin_popcount(n) const int N = 505 , M = 1e5 + 5; int n; int arr[N] , memo[N][2 * M]; int solve (int i , int d) { if (i == n) return d == M ? 0 : inf; int &ret = memo[i][d]; if (~ret) return ret; return ret = min(min(solve(i + 1 , d - arr[i]) , solve(i + 1 , d + arr[i])) , solve(i + 1 , d) + arr[i]); } int main() { freopen("input.in" , "r" , stdin); int sum = 0; cin >> n; for (int i = 0 ;i < n ;i++) { cin >> arr[i]; sum += arr[i]; } memset(memo , -1 , sizeof memo); int mnrem = solve(0 , M); int ans = (sum - mnrem) / 2 + mnrem; cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 273 ms | 395768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 267 ms | 395640 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 270 ms | 395640 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 312 ms | 395652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 312 ms | 395676 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 314 ms | 395700 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 312 ms | 395568 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 316 ms | 395588 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 315 ms | 395704 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 308 ms | 395772 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |