結果
問題 |
No.2093 Shio Ramen
|
ユーザー |
👑 |
提出日時 | 2022-10-08 00:39:05 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,365 bytes |
コンパイル時間 | 1,989 ms |
コンパイル使用メモリ | 193,728 KB |
最終ジャッジ日時 | 2025-02-08 00:08:46 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
#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 ); }