Submission #126167

# Submission time Handle Problem Language Result Execution time Memory
126167 2019-07-07T07:32:00 Z abacaba Kas (COCI17_kas) C++14
0 / 100
139 ms 2276 KB
#include <bits/stdc++.h>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

const int inf = 2e9;
const int N = 1e5 + 15;
const int M = 5e2 + 15;
int n, m, a[M], ans;
bool dp1[N], dp2[M][N];
int summ = 0;

int main() {
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		summ += a[i];
	}
	dp1[0] = dp2[n + 1][0] = 1;

	for(int i = n; i; --i)
		for(int j = N - 1; j >= 0; --j)
			if(j + a[i] < N && dp2[i + 1][j])
				dp2[i][j + a[i]] = 1;

	for(int i = 1; i <= n; ++i) {
		for(int j = N - 1; j >= 0; --j)
			if(j + a[i] < N && dp1[j])
				dp1[j + a[i]] = true;
		for(int j = N - 1; j >= 1; --j)
			if(dp1[j] && dp2[i + 1][j])
				ans = max(ans, summ - j);
	}
	cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 1256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 1640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 2276 KB Output isn't correct
2 Halted 0 ms 0 KB -