結果

問題 No.54 Happy Hallowe'en
ユーザー omochana1omochana1
提出日時 2014-12-03 00:12:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 266 ms / 5,000 ms
コード長 1,374 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 89,684 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-05 20:05:57
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 61 ms
4,380 KB
testcase_05 AC 91 ms
4,380 KB
testcase_06 AC 126 ms
4,380 KB
testcase_07 AC 173 ms
4,380 KB
testcase_08 AC 215 ms
4,384 KB
testcase_09 AC 265 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 219 ms
4,380 KB
testcase_13 AC 266 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,388 KB
testcase_18 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <map>
#include <fstream>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <set>
#include <climits>
#define MAX_N 510
#define PI 3.141592653589
#define ESP 1e-20
#define BS 10
#define MOD 1000000007 
#define ZERO 10001
#define YJSNPI 810
//#define INF (1 << 30)
#define ADD(a, b) a = (a + (ll)b) % MOD
#define MUL(a, b) a = (a * (ll)b) % MOD
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef unsigned long long ull;

int N;
int V[10010], T[10010];
int C[10010];
int dp[2][20010];

bool comp(int a, int b) {
	return V[a] + T[a] < V[b] + T[b];
}

int main() {
	scanf("%d", &N);
	for(int i = 0; i < N; i++) {
		scanf("%d%d", &V[i], &T[i]);
		C[i] = i;
	}
	sort(C, C + N, comp);
	dp[0][0] = true;
	for(int i = 0; i < N; i++) {
		int now = i % 2, next = 1 - now;
		for(int j = 0; j <= 20000; j++) {
			if(!dp[now][j]) continue;
			dp[next][j] = true;
			if(j < T[C[i]]) dp[next][j + V[C[i]]] = true;
			dp[now][j] = false;
		}
	}
	for(int i = 20000; i >= 0; i--) {
		if(dp[N % 2][i]) {
			printf("%d\n", i); return 0;
		}
	}
}
0