結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2017-03-19 11:19:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 555 bytes |
| コンパイル時間 | 1,462 ms |
| コンパイル使用メモリ | 167,060 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 23:32:41 |
| 合計ジャッジ時間 | 2,776 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 WA * 1 |
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;
int dp[1<<15];
int main(){
int N;
int M[16];
cin>>N;
REP(i,0,N){
cin>>M[i];
}
REP(i,0,1<<N) dp[i]=1e8;
int money[1<<15];
money[0]=0;
REP(i,0,1<<N){
REP(j,0,N){
if(i&1<<j) money[i]+=M[j];
}
money[i]%=1000;
}
dp[0]=0;
REP(st,0,1<<N){
REP(i,0,N){
dp[st]=min(dp[st],max(dp[st^(1<<i)],dp[st^(1<<i)]+M[i]-money[st^(1<<i)]));
}
}
p(dp[(1<<N)-1]);
return 0;
}
dnish