結果
| 問題 | No.286 Modulo Discount Store |
| コンテスト | |
| ユーザー |
TAISA_
|
| 提出日時 | 2018-06-14 22:52:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 708 bytes |
| 記録 | |
| コンパイル時間 | 1,214 ms |
| コンパイル使用メモリ | 160,184 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 14:33:47 |
| 合計ジャッジ時間 | 2,442 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int dp[1<<16];
int main(){
int n;cin>>n;
int m[16];
for(int i=0;i<n;i++){
cin>>m[i];
}
fill(dp,dp+(1<<n),INF);
dp[0]=0;
for(int i=0;i<(1<<n);i++){
int sum=0;
for(int j=0;j<n;j++){
if(i&(1<<j)){
sum+=m[j];
}
}
sum%=1000;
for(int j=0;j<n;j++){
if(!(i&(1<<j))){
dp[i|(1<<j)]=min(dp[i|(1<<j)],dp[i]+max(0,m[j]-sum));
}
}
}
cout<<dp[(1<<n)-1]<<endl;
return 0;
}
TAISA_