完全背包问题

 /*
 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. Kibana 修改logo及汉化导航

    修改此文件下E:\happy\kinbana\kibana-4.2.2-windows\kibana-4.2.2-windows\optimize\bundles的kibana.bundle.js文件 ...

  2. Careercup - Google面试题 - 5680330589601792

    2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealin ...

  3. AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet控件在C#中的引用

    这几天要是用AxMicrosoft.Office.Interop.Owc11.AxSpreadsheet控件做查询,发现一系列问题,一点点记录下来吧,以备后查: 第一.相关属性:http://www. ...

  4. 06.Hibernate实体类生命周期

        前言:Session接口是Hibernate向应用程序提供的操作数据库的主要接口,它提供了基本的增删查改方法,而且Session具有一个缓存它是Hibernate的一级缓存.站在持久化层的角度 ...

  5. bzoj 2743 树状数组离线查询

    我们按照询问的右端点排序,然后对于每一个位置,记录同颜色 上一个出现的位置,每次将上上位置出现的+1,上次出现的-1,然后 用树状数组维护就好了 /************************** ...

  6. poj 2987 Firing 最大权闭合图

    题目链接:http://poj.org/problem?id=2987 You’ve finally got mad at “the world’s most stupid” employees of ...

  7. Codeforces Round #277.5 (Div. 2)

    题目链接:http://codeforces.com/contest/489 A:SwapSort In this problem your goal is to sort an array cons ...

  8. BZOJ3130 [Sdoi2013]费用流

    AC通道:http://www.lydsy.com/JudgeOnline/problem.php?id=3130 这题codevs上也有,不过数据挂了[要A得看discuss]. 题目大意: Ali ...

  9. Rust: move和borrow

    感觉Rust官方的学习文档里关于ownship,borrow和lifetime介绍的太简略了,无法真正理解这些语法设计的原因以及如何使用(特别是lifetime).所以找了一些相关的blog来看,总结 ...

  10. Javascript全局变量的使用方法

    1.demo例子说明 <script type="text/javascript"> var gDivId; //js全局变量 function geocoder(la ...