Submission #370335

#TimeUsernameProblemLanguageResultExecution timeMemory
370335FatihSolakKas (COCI17_kas)C++17
100 / 100
208 ms196460 KiB
#include <bits/stdc++.h> #define N 505 #define M 100005 using namespace std; int dp[N][M]; int arr[N]; void solve(){ for(int j = 1;j<M;j++){ dp[0][j] = -1e9; } int n; cin >> n; for(int i=1;i<=n;i++){ cin >> arr[i]; } int sum = 0; for(int i=1;i<=n;i++){ for(int j=0;j<M;j++){ dp[i][j] = max(dp[i-1][j],max(dp[i-1][j+arr[i]],dp[i-1][abs(j-arr[i])])+arr[i]); } sum+=arr[i]; } cout << sum-dp[n][0]/2; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t=1; //cin>>t; while(t--){ solve(); } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#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...