jhsdgvawfhgjAGSWahebqwehgkwqhwqhfguwghuqwhbihvhwvuiwuievqwuiegviwiuvwqev王企鹅gbvwehvwhqegyifqgweqwijevbglowqheoghobew

尚未ac 求各路大佬求不/1000能ac的办法

#include<iostream>
#define int long long
using namespace std;
int s,n,d,zc[11],zl[11],dp[19198100];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s>>n>>d;
	for(int i=1;i<=d;i++) cin>>zc[i]>>zl[i];
	while(n--){
		for(int i=1;i<=d;i++){
			for(int j=zc[i];j<=s;j++){
				dp[j]=max(dp[j],dp[j-zc[i]]+zl[i]);
			}
		}
		s+=dp[s];
	}
	cout<<s;
	return 0;
}

2 comments

  • @ 2025-5-5 5:54:29

    / 1000代码奉上

    #include <bits/stdc++.h>
    using namespace std;
    const int N = 1e7 + 10;
    
    int m, n, year, a[N], b[N], dp[N], ans;
    
    int main()
    {
    	cin >> m >> year >> n;
    	if (m == 1e6)
    	{
    		cout << 45244600;
    		return 0;
    	}
    	ans = m;
    	for (int i = 1; i <= n; i++)
    	{
    		cin >> a[i] >> b[i];
    	}
    	
    	while (year--)
    	{
    		for (int i = 1; i <= n; i++)
    			for (int j = a[i]; j <= ans; j++)
    				dp[j] = max(dp[j], dp[j - a[i]] + b[i]);
    		ans += dp[ans];
    	}
    	
    	cout << ans;
    	
    	return 0;
    }
    
    👎 3
    • @ 2025-5-5 5:55:08

      代码造价:一次洛谷数据下载机会

    • @ 2025-5-5 13:14:35

      if (m == 1e6) { cout << 45244600; return 0; }这是在特判吗?????辣鸡特判没价值

    • @ 2025-5-5 18:34:51

      @

      	if (m == 1e6)
      	{
      		cout << 45244600;
      		return 0;
      	}
      

      ?????????? goushi 👎

    • @ 2025-5-5 18:38:46

      😭😭😭

    • @ 2025-5-5 20:18:34

      你就说是不是没写/1000吧

    • @ 2025-5-8 14:01:05

      我是历史学家 这就是史 我是诗人 这就是诗 我是大导演 这就是一场盛大的史 我是数学家 这就是十 我是矿工 这就是神金 我是地质学家 这就石沙壁

  • @ 2025-5-2 0:46:00

    可以把s、zc[i]、zl[i]全部/10,最后输出的时候再输多出个0,相当于抹掉个位

    • @ 2025-5-5 13:17:20

      a 是 1000 的倍数,b 不超过a 的 10%。b没说能整除10吧?如果b扔掉个位可能有精度误差,这样写代码可以过的话可以给洛谷加数据了👍测出了数据bug

  • 1

Information

ID
821
Time
1000ms
Memory
256MiB
Difficulty
3
Tags
# Submissions
166
Accepted
16
Uploaded By