- 投资的最大效益
因没/1000 100wa卡不知多久有感
- 2025-4-30 21:27:11 @
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
-
C24kongxiangtai LV 3 @ 2025-5-5 5:54:29Edited
无
/ 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-2 0:46:00@
可以把s、zc[i]、zl[i]全部/10,最后输出的时候再输多出个0,相当于抹掉个位
- 1
Information
- ID
- 821
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 166
- Accepted
- 16
- Uploaded By