Submission #92438

#TimeUsernameProblemLanguageResultExecution timeMemory
92438wolfKas (COCI17_kas)C++14
0 / 100
316 ms395772 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int> ; using ll = long long; #define pb push_back #define inf 0x3f3f3f3f #define all(v) (v).begin() , (v).end() #define ones(n) __builtin_popcount(n) const int N = 505 , M = 1e5 + 5; int n; int arr[N] , memo[N][2 * M]; int solve (int i , int d) { if (i == n) return d == M ? 0 : inf; int &ret = memo[i][d]; if (~ret) return ret; return ret = min(min(solve(i + 1 , d - arr[i]) , solve(i + 1 , d + arr[i])) , solve(i + 1 , d) + arr[i]); } int main() { freopen("input.in" , "r" , stdin); int sum = 0; cin >> n; for (int i = 0 ;i < n ;i++) { cin >> arr[i]; sum += arr[i]; } memset(memo , -1 , sizeof memo); int mnrem = solve(0 , M); int ans = (sum - mnrem) / 2 + mnrem; cout << ans; return 0; }

Compilation message (stderr)

kas.cpp: In function 'int main()':
kas.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.in" , "r" , stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...