結果
| 問題 |
No.286 Modulo Discount Store
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-13 20:02:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 774 bytes |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 55,412 KB |
| 最終ジャッジ日時 | 2024-11-14 19:35:34 |
| 合計ジャッジ時間 | 875 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:42: error: ‘numeric_limits’ was not declared in this scope
15 | vector<int> total_prices(1 << n, numeric_limits<int>::max());
| ^~~~~~~~~~~~~~
main.cpp:15:57: error: expected primary-expression before ‘int’
15 | vector<int> total_prices(1 << n, numeric_limits<int>::max());
| ^~~
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> product_prices(n);
for (int i = 0; i < n; i++) {
cin >> product_prices[i];
}
vector<int> total_prices(1 << n, numeric_limits<int>::max());
total_prices[0] = 0;
for (int i = 0; i < total_prices.size() - 1; i++) {
int total_price = 0;
for (int j = 0; j < n; j++) {
if ((i >> j) & 1 == 1)
total_price += product_prices[j];
}
for (int j = 0; j < n; j++) {
if ((i >> j) & 1 == 1) continue;
int price = max(0, product_prices[j] - (total_price % 1000));
total_prices[i | (1 << j)] = min(total_prices[i | (1 << j)], total_prices[i] + price);
}
}
cout << total_prices[total_prices.size() - 1] << endl;
return 0;
}