Submission #182417

#TimeUsernameProblemLanguageResultExecution timeMemory
182417awlintqaaKas (COCI17_kas)C++14
30 / 100
360 ms352640 KiB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #include <bits/stdc++.h> using namespace std; #define sqr 500 #define mid (l+r)/2 #define pb push_back #define ppb pop_back #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ins insert #define era erase #define C continue #define mem(dp,i) memset(dp,i,sizeof(dp)) #define mset multiset typedef long long ll; typedef long double ld; typedef pair<int,int> pi; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; const ll mod=1000000007;//998244353; const ll inf=1e18*4; const ld pai=acos(-1); ll n,all; ll a[509]; ll dp[509][100009]; int main(){ cin>>n; for(int i=1;i<=n;i++)cin>>a[i],all+=a[i]; ll mn=all,ans=all; dp[0][0]=1; for(int i=1;i<=n;i++){ dp[i][0]=1; for(int j=1;j<=all;j++){ dp[i][j]=dp[i-1][j]; if(j-a[i]<0)C; dp[i][j]=max(dp[i][j],dp[i-1][j-a[i]]); } for(int j=2;j<=all;j+=2){ if(dp[i][j]==dp[i][j/2] && dp[i][j]==1){ if(all-j<mn){ mn=all-j; ans=j/2+all-j; } } } } cout<<ans<<endl; }
#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...