結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
Tttt Yay
|
| 提出日時 | 2020-11-20 00:26:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 633 bytes |
| コンパイル時間 | 1,568 ms |
| コンパイル使用メモリ | 172,612 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-23 11:53:25 |
| 合計ジャッジ時間 | 2,948 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
const int mod = 1000000007;
const int INF =1e9+1;
int main(){
int n;cin>>n;
vector<int> m(n);
rep(i,n)cin>>m[i];
int n2=1<<n;
vector<pair<int,int>> dp(n2,make_pair(INF,0));
dp[0].first=0;
rep(i,n2){
rep(j,n){
if(i>>j&1)continue;
int a,b,p,q;
tie(a,b)=dp[i];
tie(p,q)=dp[i|1<<j];
if(p>a+max(0,m[j]-b%1000)){
dp[i|1<<j]=make_pair(a+max(0,m[j]-b%1000),m[j]+b);
}
}
}
cout<<dp[n2-1].first<<endl;
}
Tttt Yay