# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
298864 | shrek12357 | Kas (COCI17_kas) | C++14 | 202 ms | 176888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |