結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-05 15:56:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,531 bytes |
| コンパイル時間 | 1,686 ms |
| コンパイル使用メモリ | 170,564 KB |
| 実行使用メモリ | 9,344 KB |
| 最終ジャッジ日時 | 2024-11-27 22:20:34 |
| 合計ジャッジ時間 | 3,135 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 11 WA * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< int, int > pii;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector< pii > vp;
typedef vector< vp > vvp;
typedef vector< string > vs;
typedef vector< double > vd;
typedef vector< vd > vvd;
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 T;
int N;
vi C;
vi V;
void init(){
cin >> T;
cin >> N;
C = V = vi( N );
for( int i = 0; i < N; ++i )
cin >> C[ i ];
for( int i = 0; i < N; ++i )
cin >> V[ i ];
}
int dp[ 15 + 1 ][ 10000 + 1 ][ 8 + 1 ];
void preprocess(){
memset( dp, -1, sizeof( dp ) );
dp[ 0 ][ T ][ 0 ] = 0;
for( int i = 0; i < N; ++i )
for( int t = T; t >= 0; --t )
for( int j = 0; j <= 8; ++j )
if( dp[ i ][ t ][ j ] != -1 ){
if( j + 1 <= 8 and t - C[ i ] >= 0 )
upmax( dp[ i ][ t - C[ i ] ][ j + 1 ], dp[ i ][ t ][ j ] + ( int ) ( V[ i ] / pow( 2, j ) ) );
upmax( dp[ i + 1 ][ t ][ 0 ], dp[ i ][ t ][ j ] );
}
}
void solve(){
int ans = 0;
for( int t = 0; t <= 10000; ++t )
for( int j = 0; j <= 8; ++j )
upmax( ans, dp[ N ][ t ][ j ] );
cout << ans << endl;
}
signed main(){
ios::sync_with_stdio( 0 );
init();
preprocess();
solve();
return 0;
}