結果

問題 No.54 Happy Hallowe'en
ユーザー たこしたこし
提出日時 2018-11-20 14:42:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 1,244 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 204,648 KB
実行使用メモリ 28,044 KB
最終ジャッジ日時 2023-08-26 02:16:10
合計ジャッジ時間 2,818 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,432 KB
testcase_01 AC 2 ms
5,556 KB
testcase_02 AC 2 ms
5,440 KB
testcase_03 AC 2 ms
5,412 KB
testcase_04 AC 8 ms
13,660 KB
testcase_05 AC 9 ms
15,692 KB
testcase_06 AC 12 ms
19,908 KB
testcase_07 AC 15 ms
23,908 KB
testcase_08 AC 17 ms
27,940 KB
testcase_09 AC 20 ms
28,044 KB
testcase_10 AC 2 ms
5,428 KB
testcase_11 AC 2 ms
5,612 KB
testcase_12 AC 21 ms
27,996 KB
testcase_13 AC 20 ms
27,936 KB
testcase_14 AC 1 ms
5,400 KB
testcase_15 AC 2 ms
5,456 KB
testcase_16 AC 3 ms
5,540 KB
testcase_17 AC 2 ms
5,528 KB
testcase_18 AC 2 ms
5,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 10005;

int N;
struct VTNode {
	int v, t;
	bool operator < (const VTNode& vt) const {
		return t+v < vt.t+vt.v;
	}
}VT[MAX_N];

bitset<MAX_N*2> dp[MAX_N];

signed main()
{
	cin >> N;
	REP(n,N) {
		cin >> VT[n].v >> VT[n].t;
	}

	sort(VT, VT+N);

	dp[0].set(0);
	REP(n,N) {
		//もらわない場合
		dp[n+1] |= dp[n];
		//貰う場合
		dp[n] <<= (MAX_N*2 - VT[n].t);
		dp[n] >>= (MAX_N*2 - VT[n].t);
		dp[n] <<= VT[n].v;
		dp[n+1] |= dp[n];
		// cerr << dp[n+1].to_string() << endl;
	}

	for(int n = 2*MAX_N-1; 0 <= n; n--) {
		if(dp[N][n] == 1) {
			cout << n << endl;
			return 0;
		}
	}

	cout << 0 << endl;

	return 0;
}
0