結果

問題 No.54 Happy Hallowe'en
ユーザー
提出日時 2015-10-29 08:46:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 60,380 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 16:42:54
合計ジャッジ時間 1,541 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 11 ms
5,376 KB
testcase_05 AC 18 ms
5,376 KB
testcase_06 AC 26 ms
5,376 KB
testcase_07 AC 38 ms
5,376 KB
testcase_08 AC 49 ms
5,376 KB
testcase_09 AC 65 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 63 ms
5,376 KB
testcase_13 AC 64 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
#define INF 10000000
typedef pair<int,int> P;
int main(){
	int n;
	int v[20001],t[20001];
	P s[20001];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> v[i] >> t[i];
		s[i].first = v[i] + t[i];
		s[i].second = i;
	}
	sort(s,s+n);
	int dp[20001] ={0};
	dp[0] = 1;
	for(int i=0;i<n;i++){
		for(int j=t[s[i].second]-1;j>=0;j--){
			if(dp[j]) dp[j+v[s[i].second]] = 1;
		}
	}
	for(int i=20000;i>=0;i--){
		if(dp[i]){
			cout << i << endl;
			break;
		}
	}
}
0