結果
| 問題 | No.286 Modulo Discount Store |
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-04-07 23:58:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 853 bytes |
| 記録 | |
| コンパイル時間 | 1,753 ms |
| コンパイル使用メモリ | 54,072 KB |
| 最終ジャッジ日時 | 2024-11-14 19:40:23 |
| 合計ジャッジ時間 | 2,287 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:41:13: error: ‘accumulate’ was not declared in this scope
41 | cout << accumulate(m,m+n,0) - solve((1<<n)-1) << endl;
| ^~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
typedef long long ll;
int dp[1<<15];
int m[15];
int n;
int solve(int x) {
int i, j;
if (dp[x] >= 0)
return dp[x];
rep (i,n) {
if (x & 1<<i) {
int rest = x ^ 1<<i;
int sum = 0;
rep (j,n) {
if (rest & 1<<j)
sum += m[j];
}
dp[x] = max(dp[x],solve(rest)+min(m[i],sum%1000));
}
}
return dp[x];
}
int main() {
int i;
cin >> n;
rep (i,n) cin >> m[i];
fill(dp+1,dp+(1<<n),-1);
cout << accumulate(m,m+n,0) - solve((1<<n)-1) << endl;
return 0;
}
h_noson