結果

問題 No.2093 Shio Ramen
ユーザー 👑 p-adicp-adic
提出日時 2022-10-08 00:39:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,365 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 198,052 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 17:32:24
合計ジャッジ時間 4,456 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 3 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 3 ms
4,384 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) 
#define CIN( LL , A ) LL A; cin >> A 
#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type
#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) 
#define FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) 
#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) 
#define QUIT return 0 
#define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT 

int main()
{
  UNTIE;
  CIN( int , N );
  assert( 1 <= N && N <= 1000 );
  CIN( uint , I );
  assert( 1 <= I && I <= 1000 );
  // (N∪{-∞},max,×)[X]/(X^{I+1})の多項式乗算
  uint f[1001] = {};
  f[0] = 1;
  uint s;
  uint a;
  uint d;
  uint degree;
  REPEAT( N ){
    cin >> s >> a;
    assert( 1 <= s && s <= 1000 );
    assert( 1 <= a && a <= 1000 );
    d = I - s;
    while( true ){
      if( f[d] != 0 ){
	degree = f[d] + a;
	if( f[d + s] < degree ){
	  f[d + s] = degree;
	}
      }
      if( d == 0 ){
	break;
      } else {
	d--;
      }
    }
  }
  uint degree_max = 0;
  FOREQ( d , 0 , I ){
    if( degree_max < f[d] ){
      degree_max = f[d];
    }
  }
  RETURN( degree_max - 1 );  
}

0