結果
問題 |
No.54 Happy Hallowe'en
|
ユーザー |
|
提出日時 | 2016-12-21 19:37:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 5,000 ms |
コード長 | 1,300 bytes |
コンパイル時間 | 1,844 ms |
コンパイル使用メモリ | 174,936 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 12:32:17 |
合計ジャッジ時間 | 2,916 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; int N; vp v_t; void init(){ cin >> N; v_t = vp( N ); for( int i = 0; i < N; ++i ) cin >> v_t[ i ].first >> v_t[ i ].second; } const int MAXT = ( int ) 1e4; const int MAXV = ( int ) 1e4; int dp[ MAXT + MAXV + 1 ]; void preprocess(){ sort( v_t.begin(), v_t.end(), [ & ]( pii a, pii b ){ return a.first + a.second < b.first + b.second; } ); dp[ 0 ] = 1; for( int i = 0; i < N; ++i ) for( int j = v_t[ i ].second - 1; j >= 0; --j ) dp[ j + v_t[ i ].first ] |= dp[ j ]; } void solve(){ for( int i = MAXT + MAXV; i >= 0; --i ) if( dp[ i ] ) cout << i << endl, exit( 0 ); } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }