# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
227581 |
2020-04-28T01:14:06 Z |
mohamedsobhi777 |
Kas (COCI17_kas) |
C++14 |
|
633 ms |
216628 KB |
#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5 + 7 ;
int offset = 1e5 + 7 ;
int n , sum;
int a[N] ;
int dp[552][N] ;
int solve(int i , int k){
if(~dp[i][k])return dp[i][k] ;
if(i==n)return (k==offset ? 0 : 1e9) ;
return dp[i][k] = min( min( solve(i+1 , k + a[i]) , solve(i+1 , k - a[i]) ) , solve(i+1 , k) + a[i] ) ;
}
int main(){
memset(dp , -1 , sizeof dp) ;
ios_base::sync_with_stdio(0) ;
cin.tie(0);
cin>>n ;
for(int i = 0 ;i < n;i++){
cin>>a[i];
sum+=a[i] ;
}
int mn = solve(0 , offset) ;
cout<<(sum - mn) /2 + mn ;
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
216440 KB |
Output is correct |
2 |
Correct |
105 ms |
216440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
216440 KB |
Output is correct |
2 |
Correct |
108 ms |
216416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
216440 KB |
Output is correct |
2 |
Correct |
114 ms |
216396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
216440 KB |
Output is correct |
2 |
Correct |
104 ms |
216424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
216440 KB |
Output is correct |
2 |
Correct |
107 ms |
216440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
216440 KB |
Output is correct |
2 |
Correct |
109 ms |
216440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
216440 KB |
Output is correct |
2 |
Correct |
108 ms |
216444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
206 ms |
216440 KB |
Output is correct |
2 |
Correct |
133 ms |
216440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
221 ms |
216468 KB |
Output is correct |
2 |
Correct |
297 ms |
216628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
406 ms |
216440 KB |
Output is correct |
2 |
Incorrect |
633 ms |
216580 KB |
Output isn't correct |