結果

問題 No.54 Happy Hallowe'en
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-16 05:12:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 151,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-05 20:09:27
合計ジャッジ時間 2,215 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 10 ms
4,376 KB
testcase_06 AC 14 ms
4,380 KB
testcase_07 AC 20 ms
4,376 KB
testcase_08 AC 27 ms
4,376 KB
testcase_09 AC 33 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 33 ms
4,380 KB
testcase_13 AC 33 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++)
#define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++)
#define all(n) (n).begin(),(n).end()
typedef long long ll;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<long long,long long> Pii;
typedef vector<Pii> VPii;


bool dp[20010];
int main(){
	int N;
	cin >> N;
	vector< pair<int,int> > v;
	for(int i = 0 ; i < N ; i++){
		int V,T;
		cin >> V >> T;
		v.push_back({T+V,V});
	}
	sort(v.begin(),v.end());
	dp[0] = 1;
	for(auto i : v ){
		int V = i.second;
		int T = i.first - V;
		for(int j = T - 1 ; j >= 0 ; j--)
			dp[j+V] |= dp[j];
	}
	for(int i = 20000 ; i >= 0 ; i--)
		if( dp[i] ){
			cout << i << endl;
			return 0;
		}
	
}
0