完全背包问题

 /*
 ID: yingzho1
 LANG: C++
 TASK: inflate
 */
 #include <iostream>
 #include <fstream>
 #include <string>
 #include <map>
 #include <vector>
 #include <set>
 #include <algorithm>
 #include <stdio.h>
 #include <queue>
 #include <cstring>
 #include <cmath>
 #include <list>

 using namespace std;

 ifstream fin("inflate.in");
 ofstream fout("inflate.out");

 ;

 struct cat {
     int point;
     int time;
     cat(int a, int b) : point(a), time(b) { }
     cat() : point(), time() { }
 };

 int total_time;
 int N;

 int main()
 {
     fin >> total_time >> N;
     vector<cat> pro(N);
     ; i < N; i++) {
         fin >> pro[i].point >> pro[i].time;
     }
     vector<);
     ; i < N; i++) {
         ; j*pro[i].time < total_time; j++) {
             ; j*pro[i].time+k <= total_time && k <= pro[i].time; k++) {
                 /*if (f[j*pro[i].time+k] < f[(j-1)*pro[i].time+k]+pro[i].point) {
                     f[j*pro[i].time+k] = f[(j-1)*pro[i].time+k]+pro[i].point;
                     cout << "f[" << j*pro[i].time+k << "]: " << f[j*pro[i].time+k] << endl;
                 }*/
                 f[j*pro[i].time+k] = max(f[j*pro[i].time+k], f[(j-)*pro[i].time+k]+pro[i].point);
                 //cout << "f[" << j*pro[i].time+k << "]: " << f[j*pro[i].time+k] << endl;
             }
         }
     }
     fout << f[total_time] << endl;

     ;
 }

USACO Section 3.1: Score Inflation的更多相关文章

  1. 【USACO 3.1】Score Inflation(完全背包)

    完全背包. http://train.usaco.org/usacoprob2?a=3Srffjlf4QI&S=inflate /* TASK:inflate LANG:C++ URL: */ ...

  2. USACO Score Inflation

    洛谷 P2722 总分 Score Inflation https://www.luogu.org/problem/P2722 JDOJ 1697: Score Inflation https://n ...

  3. 洛谷P2722 总分 Score Inflation

    P2722 总分 Score Inflation 184通过 295提交 题目提供者该用户不存在 标签USACO 难度普及- 提交  讨论  题解 最新讨论 关于算法 题目背景 学生在我们USACO的 ...

  4. 洛谷——P2722 总分 Score Inflation(背包)

    P2722 总分 Score Inflation 题目背景 学生在我们USACO的竞赛中的得分越多我们越高兴. 我们试着设计我们的竞赛以便人们能尽可能的多得分,这需要你的帮助 题目描述 我们可以从几个 ...

  5. P2722 总分 Score Inflation (完全背包模板)

    题目传送门:P2722 总分 Score Inflation 题目描述 我们可以从几个种类中选取竞赛的题目,这里的一个"种类"是指一个竞赛题目的集合,解决集合中的题目需要相同多的时 ...

  6. USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)

    usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...

  7. 洛谷——2722总分 Score Inflation

    题目背景 学生在我们USACO的竞赛中的得分越多我们越高兴. 我们试着设计我们的竞赛以便人们能尽可能的多得分,这需要你的帮助 题目描述 我们可以从几个种类中选取竞赛的题目,这里的一个"种类& ...

  8. AC日记——总分 Score Inflation 洛谷 P2722

    题目背景 学生在我们USACO的竞赛中的得分越多我们越高兴. 我们试着设计我们的竞赛以便人们能尽可能的多得分,这需要你的帮助 题目描述 我们可以从几个种类中选取竞赛的题目,这里的一个"种类& ...

  9. 洛谷——P2722 总分 Score Inflation

    https://www.luogu.org/problem/show?pid=2722 题目背景 学生在我们USACO的竞赛中的得分越多我们越高兴. 我们试着设计我们的竞赛以便人们能尽可能的多得分,这 ...

随机推荐

  1. java导出excel表格

    java导出excel表格: 1.导入jar包 <dependency> <groupId>org.apache.poi</groupId> <artifac ...

  2. Alt.js的入门

    一.什么是Alt altJS是基于Flux使用Javascript应用来管理数据的类库,它简化了flux的store.actions.dispatcher. 关于Flux,以下链接都做了很好的诠释 h ...

  3. PHP数组的定义和遍历

    //常用函数//生成随机数//echo rand(3,33); //两个参数来确定随机数的范围为3-33 //日期时间函数echo time(); //取当前时间的UNIX时间戳//date_defa ...

  4. 浅谈GitHub

    Git 是一个面向开源及私有软件项目的托管平台,因为只支持Git作为唯一的版本库格式进行托管,故名GitHub. Gith是一个基于 git 的社会化代码分享社区,所谓 social coding.你 ...

  5. 系统集成之用户统一登录( LDAP + wso2 Identity Server)

    本文场景: LDAP + wso2 Identity Server + asp.net声明感知 场景 ,假定读者已经了解过ws-*协议族,及 ws-trust 和 ws-federation. 随着开 ...

  6. JavaScript之arguments对象讲解

    javascript的arguments对象类似于PHP的extract()函数实现. 在不确定函数参数个数的情况下,可以通过arguments访问参数,并以索引0为起始. function sayH ...

  7. The life of an HTML HTTP request

    https://developer.mozilla.org/en-US/docs/The_life_of_an_HTML_HTTP_request http://www.html5rocks.com/ ...

  8. Razor语法学习

    原文:http://www.cnblogs.com/youring2/archive/2011/07/24/2115254.html 1.Razor的文件类型 Razor支持两种文件类型,分别是.cs ...

  9. POJ 3320

    Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6496   Accept ...

  10. php接收数据

    http://lpladdyy.blog.163.com/blog/static/133999664201010264264585/ PHP默认只识别application/x-www.form-ur ...