1 条题解

  • 0
    @ 2025-3-15 22:10:56
    #include <bits/stdc++.h>
    
    using u32 = unsigned;
    using i64 = long long;
    using u64 = unsigned long long;
    using u128 = unsigned __int128;
    
    int main() {
    	std::ios::sync_with_stdio(false);
    	std::cin.tie(nullptr);
    
    	int n, m;
    	std::cin >> n >> m;
    	std::vector<i64> dp(m + 1);
    
    	for (int i = 1; i <= n; i ++) {
    		int v, w;
    		std::cin >> v >> w;
    		for (int j = m; j >= v; j--) {
    			dp[j] = std::max(dp[j], dp[j - v] + w);
    		}
    	}
    
    	std::cout << dp[m] << "\n";
    
    
    	return 0;
    }
    
    • 1

    信息

    ID
    193
    时间
    1000ms
    内存
    256MiB
    难度
    5
    标签
    (无)
    递交数
    29
    已通过
    15
    上传者