結果
| 問題 | 
                            No.54 Happy Hallowe'en
                             | 
                    
| コンテスト | |
| ユーザー | 
                             はまやんはまやん
                         | 
                    
| 提出日時 | 2016-06-11 17:09:39 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 119 ms / 5,000 ms | 
| コード長 | 842 bytes | 
| コンパイル時間 | 1,688 ms | 
| コンパイル使用メモリ | 171,016 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-15 17:14:50 | 
| 合計ジャッジ時間 | 3,121 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N;
pair<int, int> VT[10101];
bool dp[2][10101];
bool comp(pair<int, int> a, pair<int, int> b)
{
	return (a.second + a.first) < (b.first + b.second);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> N)
	{
		rep(i, 0, N)
		{
			int v, t; cin >> v >> t;
			VT[i] = make_pair(v, t);
		}
		sort(VT, VT + N, comp);
		
		rep(i, 0, 2) rep(j, 0, 10101) dp[i][j] = false;
		dp[0][0] = true;
		int ans = 0;
		rep(i, 0, N)
		{
			int ii = i + 1;
			rep(j, 0, 10101) dp[ii % 2][j] = false;
			rep(j, 0, 10101) if (dp[i % 2][j])
			{
				dp[ii % 2][j] = true;
				if (j < VT[i].second)
				{
					int jj = j + VT[i].first;
					ans = max(ans, jj);
					if(jj < 10000) dp[ii % 2][jj] = true;
				}
			}
		}
		cout << ans << endl;
	}
}
            
            
            
        
            
はまやんはまやん