提交时间:2024-04-07 13:56:02
运行 ID: 142372
# include <bits/stdc++.h> using namespace std ; long long tme [10005] , vle [10005] , dp [10005] ; int main ( ) { int t , m ; cin >> t >> m ; for ( int i = 1 ; i <= m ; i ++ ) { cin >> tme [i] >> vle [i] ; } for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = t ; j >= tme [i] ; j -- ) { dp [j] = max ( dp [j] , dp [j - tme [i]] + vle [i] ) ; } } cout << dp [t] << endl ; return 0 ; }