結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
tokkaka
|
| 提出日時 | 2016-07-29 22:22:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 848 bytes |
| コンパイル時間 | 651 ms |
| コンパイル使用メモリ | 86,080 KB |
| 最終ジャッジ日時 | 2024-11-14 19:48:07 |
| 合計ジャッジ時間 | 1,074 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:23:26: error: 'numeric_limits' was not declared in this scope
23 | vector<int> dp(1<<N, numeric_limits<int>::max());
| ^~~~~~~~~~~~~~
main.cpp:23:41: error: expected primary-expression before 'int'
23 | vector<int> dp(1<<N, numeric_limits<int>::max());
| ^~~
ソースコード
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <tuple>
#include <climits>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> M(N);
for(auto &m : M) cin >> m;
vector<int> dp(1<<N, numeric_limits<int>::max());
dp[0] = 0;
for(int i=0; i<(1<<N)-1; i++) {
int total = 0;
for(int j=0; j<N; j++)
total += (i&(1<<j))!=0?M[j]:0;
total %= 1000;
for(int j=0; j<N; j++) {
if((i&(1<<j)) == 0) {
int a = dp[i] + std::max(0, M[j]-total);
dp[i | (1<<j)] = std::min(dp[i | (1<<j)], a);
}
}
}
cout << dp[(1<<N) - 1] << endl;
}
tokkaka