Metal Steak

Hard to eat

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  0 Posts :: 79 Stories :: 0 Comments :: 0 Trackbacks

公告

aaaaaaaaaaaa

常用链接

留言簿(1)

我参与的团队

搜索

  •  

最新评论

#include <iostream>
using namespace std;

int
n, sigmat, ans[
10001], score, costt;


void
__read__()
{
    cin 
>> sigmat >> n;
}

void
__dp__()
{
    
forint i = 1; i <= n; i++ )
    {
        cin 
>> score >> costt;
        
forint j = costt; j <= sigmat; j++ )
            
if( ans[j - costt] + score > ans[j] )
                ans[j] 
= ans[j - costt] + score;
    }
}

void
__outp__()
{
    cout 
<< ans[sigmat] << endl;
}

int
main()
{
    __read__();
    __dp__();
    __outp__();

    
return 0;
}

posted on 2009-09-15 20:56 mad4alcohol 阅读(58) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理