답안 #182415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
182415 2020-01-09T18:49:52 Z awlintqaa Kas (COCI17_kas) C++14
30 / 100
381 ms 352656 KB
#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=inf,ans=-1;
        for(int i=1;i<=n;i++){
                dp[i-1][0]=1;
                for(int j=1;j<=1e5;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<=1e5;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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8184 KB Output is correct
2 Correct 11 ms 8184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8184 KB Output is correct
2 Incorrect 11 ms 8184 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8184 KB Output is correct
2 Correct 12 ms 8952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 9720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 10488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 27740 KB Output is correct
2 Incorrect 36 ms 31608 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 35692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 168 ms 156852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 254 ms 235228 KB Output is correct
2 Correct 337 ms 313508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 381 ms 352656 KB Output isn't correct
2 Halted 0 ms 0 KB -