Skip to content

Instantly share code, notes, and snippets.

@Hunachi
Created November 25, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hunachi/4fcd9c2bc680a481062d90a4bc611542 to your computer and use it in GitHub Desktop.
Save Hunachi/4fcd9c2bc680a481062d90a4bc611542 to your computer and use it in GitHub Desktop.
#include<iostream>
/**省略**/
int n,m;///制限
int dp[1000000001],d[1002];
/**省略**/
int main(){
dp[0]=1;
rep(i,0,n){
repm(j,10000001,0){
if(dp[j]){
if(dp[d[i]+j]){
dp[d[i]+j]=min(dp[j]+1,dp[d[i]+j]);
}else{
dp[d[i]+j]=dp[j]+1;
}
}
}
}
int ans = 0;
rep(i,0,m+1){
///1からだから5
if(dp[i]>0&&dp[i]<=5){
ans=i;
}
}
cout << ans << endl;
}
@Hunachi
Copy link
Author

Hunachi commented Nov 25, 2016

This Code is explode memories & times.
problem : JOI 2008 Darts. //AOJ 0529 problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment