# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298864 | 2020-09-14T08:35:00 Z | shrek12357 | Kas (COCI17_kas) | C++14 | 202 ms | 176888 KB |
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> using namespace std; const int MAXV = 1e5+5; #define MAXN 505 int main() { int dp[MAXN][MAXV]; int best = 0; int n; cin >> n; vector<int> nums; int sum = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < MAXV; j++) { dp[i][j] = -1; } } dp[0][0] = 0; for (int i = 0; i < n; i++) { int temp; cin >> temp; nums.push_back(temp); sum += temp; } for (int i = 0; i < n; i++) { for (int j = 0; j < MAXV; j++) { if (dp[i][j] >= 0) { dp[i + 1][j + nums[i]] = max(dp[i + 1][j + nums[i]], dp[i][j] + nums[i]); dp[i + 1][abs(j - nums[i])] = max(dp[i + 1][abs(j - nums[i])], dp[i][j] + nums[i]); dp[i + 1][j] = (dp[i + 1][j], dp[i][j]); } } best = max(best, dp[i + 1][0]); } cout << best/2 + sum-best << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 4224 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4224 KB | Output is correct |
2 | Incorrect | 5 ms | 4224 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4224 KB | Output is correct |
2 | Incorrect | 4 ms | 4608 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 4992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5376 KB | Output is correct |
2 | Incorrect | 6 ms | 5504 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 14080 KB | Output is correct |
2 | Incorrect | 16 ms | 16000 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 17920 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 100 ms | 78840 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 120 ms | 117880 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 202 ms | 176888 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |