結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2023-03-24 03:26:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 524 bytes |
| コンパイル時間 | 2,844 ms |
| コンパイル使用メモリ | 247,712 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-18 15:50:29 |
| 合計ジャッジ時間 | 4,292 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int n;
cin>>n;
vector<ll> dp(1<<n,1e12);
dp[0] = 0;
vector<ll> m(n);
for(int i = 0;i<n;i++) cin>>m[i];
for(int i = 0;i<1<<n;i++){
ll now = 0;
for(int j = 0;j<n;j++) if(i>>j&1) now += m[j];
now %= 1000;
for(int j = 0;j<n;j++) if(~i>>j&1){
ll use = max(0LL,m[j]-now);
dp[i|1<<j] = min(dp[i|1<<j],dp[i]+use);
}
}
cout<<dp.back()<<endl;
}
momoyuu