| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 934499 | TIN | Kas (COCI17_kas) | C++17 | 157 ms | 1784 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = 2e9;
void Task() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(9);
	if (fopen("test.inp","r")) {
		freopen("test.inp","r",stdin);
		freopen("test.out","w",stdout);
	}
}
void Solve() {
	//Your Code
	int n;
	cin >> n;
	vector<int> dp1, dp2;
	dp1.resize(MAXN, INF);
	dp2.resize(MAXN);
	dp1[0] = 0;
	int sum = 0;
	for (int j = 0; j < n; j++) {
		int x;
		cin >> x;
		sum += x;
		dp2 = dp1;
		dp1.assign(dp1.size(), INF);
		for (int v = 0; v < MAXN; ++v) {
			if (x + v < MAXN) dp1[x + v] = min(dp1[x + v], dp2[v]);
			dp1[abs(v - x)] = min(dp1[abs(v - x)], dp2[v]);
			dp1[v] = min(dp1[v], dp2[v] + x);
		}
	}
	cout << (sum - dp1[0]) / 2 + dp1[0] << '\n';
}
int main() {
	Task();
	Solve();
	cerr << "\nTime run: " << 1000*clock()/CLOCKS_PER_SEC << "ms";
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
