# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
126790 | 2019-07-08T12:03:35 Z | abacaba | Kas (COCI17_kas) | C++14 | 257 ms | 44512 KB |
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const int M = 1e5 + 15; const int N = 5e2 + 15; int n, a[N], summ, ans = inf; bool dp1[M], dp2[N][M]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%d", &a[i]); summ += a[i]; } dp2[n+1][0] = 1; dp1[0] = 1; for(int i = n; i; --i) { for(int j = M - 1; j >= 0; --j) dp2[i][j] = dp2[i+1][j]; for(int j = M - 1; j >= 0; --j) if(dp2[i][j] && j + a[i] < M) dp2[i][j + a[i]] = 1; } for(int i = 1; i <= n; ++i) { for(int j = M - 1; j >= 0; --j) if(dp1[j] && j + a[i] < M) dp1[j + a[i]] = 1; for(int j = M - 1; j; --j) if(dp1[j] && dp2[i + 1][j]) ans = min(ans, summ - (j << 1)); } cout << ans + (summ - ans) / 2; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1272 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1272 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1272 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1528 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1656 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 17 ms | 3832 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 4728 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 104 ms | 20024 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 141 ms | 29688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 257 ms | 44512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |