結果
| 問題 | No.54 Happy Hallowe'en |
| コンテスト | |
| ユーザー |
Ysmr_Ry
|
| 提出日時 | 2014-12-14 10:44:25 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 5,000 ms |
| コード長 | 850 bytes |
| 記録 | |
| コンパイル時間 | 384 ms |
| コンパイル使用メモリ | 58,472 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-05-05 04:37:41 |
| 合計ジャッジ時間 | 1,556 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<utility>
#define rep(i,a) for(int i=0;i<(a);++i)
#define repd(i,a) for(int i=(a);i>=0;--i)
#define clr(a,v) memset((a),(v),sizeof(a))
typedef std::pair<int, int> P;
const int MAX_N = 10000;
int N;
P ps[MAX_N];
bool dp[MAX_N+1];
int main()
{
scanf( "%d", &N );
rep( i, N )
{
int V, T;
scanf( "%d%d", &V, &T );
ps[i] = P( V, T );
}
std::sort( ps, ps+N, []( const P &lhs, const P &rhs ){ return lhs.first+lhs.second < rhs.first+rhs.second; } );
clr( dp, false );
dp[0] = true;
int ans = 0;
rep( i, N )
{
repd( j, ps[i].second-1 )
{
if( !dp[j] )
continue;
ans = std::max( ans, j+ps[i].first );
if( j+ps[i].first <= MAX_N )
dp[j+ps[i].first] |= dp[j];
}
}
printf( "%d\n", ans );
return 0;
}
Ysmr_Ry