結果

問題 No.54 Happy Hallowe'en
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-16 05:12:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 164,584 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 16:43:28
合計ジャッジ時間 2,045 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 7 ms
6,940 KB
testcase_05 AC 11 ms
6,940 KB
testcase_06 AC 16 ms
6,940 KB
testcase_07 AC 24 ms
6,940 KB
testcase_08 AC 31 ms
6,940 KB
testcase_09 AC 40 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 39 ms
6,940 KB
testcase_13 AC 40 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 1 ms
6,944 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