結果

問題 No.286 Modulo Discount Store
ユーザー saytakaPCsaytakaPC
提出日時 2015-10-09 22:56:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 1,042 ms
コンパイル使用メモリ 147,000 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 10:14:31
合計ジャッジ時間 3,735 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 32 ms
4,376 KB
testcase_02 AC 67 ms
4,380 KB
testcase_03 AC 15 ms
4,376 KB
testcase_04 AC 22 ms
4,376 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 76 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 61 ms
4,376 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 14 ms
4,376 KB
testcase_13 AC 69 ms
4,376 KB
testcase_14 AC 8 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 31 ms
4,376 KB
testcase_17 AC 82 ms
4,384 KB
testcase_18 AC 59 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 45 ms
4,376 KB
testcase_21 AC 11 ms
4,376 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 68 ms
4,376 KB
testcase_24 AC 11 ms
4,376 KB
testcase_25 AC 54 ms
4,376 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 53 ms
4,376 KB
testcase_28 AC 74 ms
4,376 KB
testcase_29 AC 8 ms
4,384 KB
testcase_30 AC 8 ms
4,380 KB
testcase_31 AC 42 ms
4,380 KB
testcase_32 AC 40 ms
4,376 KB
testcase_33 AC 11 ms
4,376 KB
testcase_34 AC 10 ms
4,380 KB
testcase_35 AC 29 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 58 ms
4,380 KB
testcase_38 AC 5 ms
4,376 KB
testcase_39 AC 81 ms
4,380 KB
testcase_40 AC 6 ms
4,380 KB
testcase_41 AC 6 ms
4,376 KB
testcase_42 AC 13 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int dp[1<<15];
int n,m[15];
int main(){
      cin>>n;
      REP(i,n)cin>>m[i];
      REP(i,1<<n)dp[i]=INF;
      dp[0]=0;
      REP(i,n+1){
            if(i==0)continue;
            REP(j,1<<15){
                  int cnt=0,sum=0;
                  vector<int> v;
                  REP(k,n)if(j>>k&1){
                        cnt++;
                        sum+=m[k];
                        v.PB(k);
                  }
                  if(cnt!=i)continue;
                  REP(k,i){
                        int t=j;
                        t-=(1<<v[k]);
                        dp[j]=min(dp[j],dp[t]+max(0,m[v[k]]-(sum-m[v[k]])%1000));
                  }
            }
      }
      //REP(i,1<<n)cout<<dp[i]<<endl;
      cout<<dp[(1<<n)-1]<<endl;
}
0