結果
| 問題 |
No.974 最後の日までに
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-01-17 22:37:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 804 bytes |
| コンパイル時間 | 1,611 ms |
| コンパイル使用メモリ | 169,052 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 22:15:34 |
| 合計ジャッジ時間 | 8,717 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 RE * 39 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<long long> a(n), b(n), c(n);
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i] >> c[i];
}
long long s = accumulate(begin(a), end(a), 0LL);
assert(n <= 24);
long long res = 0;
for (int bt = 0; bt < 1 << n; bt += 2) {
bool ok = true;
for (int i = 1; i < n; ++i) {
if (bt >> i & 1 and bt >> (i - 1) & 1) {
ok = false;
break;
}
}
if (not ok) {
continue;
}
long long sw = 0, sv = 0;
for (int i = 0; i < n; ++i) {
if (bt >> i & 1) {
sw += a[i - 1] + a[i] + c[i];
sv += b[i];
}
}
if (sw <= s) {
res = max(res, sv);
}
}
cout << res << '\n';
}
risujiroh