結果
| 問題 |
No.54 Happy Hallowe'en
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-03 16:40:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,672 bytes |
| コンパイル時間 | 1,090 ms |
| コンパイル使用メモリ | 92,416 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-16 06:33:20 |
| 合計ジャッジ時間 | 97,893 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <memory>
#include <chrono>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
int main() {
int n; cin >> n;
vector<int> v(n), t(n); repeat (i,n) cin >> v[i] >> t[i];
vector<int> ix(n);
whole(iota, ix, 0);
whole(sort, ix, [&](int i, int j) { return t[i] < t[j]; });
int ans = -1;
chrono::high_resolution_clock::time_point clock_begin = chrono::high_resolution_clock::now();
while (true) {
chrono::high_resolution_clock::time_point clock_end = chrono::high_resolution_clock::now();
if (chrono::duration_cast<chrono::milliseconds>(clock_end - clock_begin).count() >= 4800) break;
auto dp = make_unique<bitset<2*10000+1> >();
(*dp)[0] = true;
whole(random_shuffle, ix);
for (int i : ix) {
auto it = make_unique<bitset<2*10000+1> >();
it->flip();
*it <<= t[i];
it->flip();
*it &= *dp;
*it <<= v[i];
*dp |= *it;
}
repeat_reverse (i,dp->size()) {
if ((*dp)[i]) setmax(ans, i);
if (i == ans) break;
}
}
cout << ans << endl;
return 0;
}