Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
145489 | 梁乃元 | 收益 | C++ | 通过 | 100 | 3 MS | 4160 KB | 676 | 2024-05-05 10:24:17 |
# include <bits/stdc++.h> using namespace std ; int t , amount , n , d ; int weight [12] , profit [12] , dp [1000002] ; int main ( ) { cin >> t ; while ( t -- ) { memset ( dp , 0 , sizeof ( dp ) ) ; cin >> amount >> n >> d ; for ( int i = 0 ; i < d ; i ++ ) { cin >> weight [i] >> profit [i] ; weight [i] /= 1000 ; } for ( int i = 0 ; i < n ; i ++ ) { int t1 = amount / 1000 ; for ( int j = 0 ; j < d ; j ++ ) { for ( int k = weight [j] ; k <= t1 ; k ++ ) { dp [k] = max ( dp [k] , dp [k - weight [j]] + profit [j] ) ; } } amount += dp [t1] ; } cout << amount << endl ; } return 0 ; }