关闭

Score Inflation_usaco3.1.2_dp

标签: dpc++usaco完全背包
237人阅读 评论(0) 收藏 举报
分类:

DESCRIPTION


The more points students score in our contests, the happier we here at the USACO are. We try to design our contests so that people can score as many points as possible, and would like your assistance.

We have several categories from which problems can be chosen, where a “category” is an unlimited set of contest problems which all require the same amount of time to solve and deserve the same number of points for a correct solution. Your task is write a program which tells the USACO staff how many problems from each category to include in a contest so as to maximize the total number of points in the chosen problems while keeping the total solution time within the length of the contest.

The input includes the length of the contest, M (1 <= M <= 10,000) (don’t worry, you won’t have to compete in the longer contests until training camp) and N, the number of problem categories, where 1 <= N <= 10,000.

Each of the subsequent N lines contains two integers describing a category: the first integer tells the number of points a problem from that category is worth (1 <= points <= 10000); the second tells the number of minutes a problem from that category takes to solve (1 <= minutes <= 10000).

Your program should determine the number of problems we should take from each category to make the highest-scoring contest solvable within the length of the contest. Remember, the number from any category can be any nonnegative integer (0, one, or many). Calculate the maximum number of possible points.

PROGRAM NAME: inflate


INPUT FORMAT


Line 1: M, N – contest minutes and number of problem classes
Lines 2-N+1: Two integers: the points and minutes for each class

OUTPUT FORMAT


A single line with the maximum number of points possible given the constraints.

ANALYSIS


完全背包的模板,套一套就好了
我也不是很懂刷这种题目的意义;-p

CODE


/*
ID:wjp13241
PROG:inflate
LANG:C++
*/
#include <stdio.h>
using namespace std;
int f[10101];
int w[10101],v[10101];
int max(int x,int y)
{
    return x>y?x:y;
}
int main()
{
    freopen("inflate.in","r",stdin);
    freopen("inflate.out","w",stdout);
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
        scanf("%d%d",&v[i],&w[i]);
    for (int i=1;i<=m;i++)
        for (int j=w[i];j<=n;j++)
            f[j]=max(f[j],f[j-w[i]]+v[i]);
    printf("%d\n",f[n]);
    return 0;
}
1
0
查看评论

【USACO3.1.2】总分 背包问题动态规划

完全背包问题。 f[i][j]表示用前j个物品,放满i的空间,能取得最大价值。 f[i][j] =max  f[i - a[P]]j - 1] + b[P]   j按顺序用的话,数组第二维可以压掉。即为f[i] = max f[i - a[P]] + b[P]...
  • baidu_23081367
  • baidu_23081367
  • 2015-02-18 13:09
  • 310

USACO3.1.2 Score Inflation (inflate)

裸的完全背包。/* ID:shijiey1 PROG:inflate LANG:C++ */ #include #include #include using namespace std; int m, n; int sco[10010]; int tim[10010]; int dp[1...
  • u011265346
  • u011265346
  • 2014-12-10 09:00
  • 273

USACO 3.1.2 Score Inflation

裸完全背包. /* * USACO3.1.2.cpp * * Created on: Jun 7, 2013 * Author: root */ #include #include #include using namespace std; const int max...
  • zxjcarrot
  • zxjcarrot
  • 2013-06-07 22:29
  • 383

Inception Score&Mode Score

Inception ScoreMode ScoreReference[1]Tong Che, Yanran Li, Athul Paul Jacob, Yoshua Bengio, Wenjie Li. Mode Regularized Generative Adversarial Networks...
  • SPARKKKK
  • SPARKKKK
  • 2017-05-19 21:00
  • 1405

#目标检测#对R-FCN网络以及position-sensitive score map的理解

引言 R-FCN网络是Faster R-CNN之后又一个比较著名的基于Region Proposal的目标检测网络,它可以达到与Faster R-CNN相近的mAP,且速度要快好几倍。 R-FCN论文原文:R-fcn: Object detection via region-based full...
  • Blateyang
  • Blateyang
  • 2017-12-02 21:22
  • 340

solr如何计算score?

solr计算一个query的score分为两个部分: Lucene的算分模型Boost 其中Lucene的算分模型包括: 1. tf - Term Frequency. The frequency with which a term appears in a document. Given a s...
  • wgw335363240
  • wgw335363240
  • 2014-07-18 16:34
  • 3597

score

import java.util.Scanner; public class score { public static void main(String args[]){ Scanner sc=new Scanner(System.in); while(sc.hasNextDouble...
  • u014005184
  • u014005184
  • 2014-04-14 15:28
  • 355

机器学习知识点(三十六)分类器性能度量指标f1-score

在用python机器学习库scikit-learn训练模型时,常用f1-score来度量模型性能,下面回顾和学习下这个指标。 内容概要¶ 模型评估的目的及一般评估流程分类准确率的用处及其限制混淆矩阵(confusion matrix)是如何表示一个分类器的性能混淆矩阵中的度...
  • fjssharpsword
  • fjssharpsword
  • 2017-06-15 00:05
  • 2714

solr排序过滤score过低的结果

在solr搜索中,我们免不了要将搜索的结果按照一定的规则排序。然而,在排序的过程中我们经常会用到Analyzer,这会使得排序的结果中出现相关度并不高的结果,特别是可能会出现排名靠前然而相关度并不高,甚至风马牛不相及的结果,实在是蛋疼无比,大大降低用户体验。那么有什么办法可以在排序时过滤掉这些结果呢...
  • u014527058
  • u014527058
  • 2017-02-10 15:44
  • 1807

solr score打分模式及其问题

 在新房索引实例中,根据"qf": "sName^3 sAddress^0.8 sDesc^0.5", 搜索:绿地 中央 1、搜索相关参数为:    "params": ...
  • u012448083
  • u012448083
  • 2016-12-28 13:39
  • 1968
    个人资料
    • 访问:113529次
    • 积分:6947
    • 等级:
    • 排名:第3961名
    • 原创:561篇
    • 转载:7篇
    • 译文:0篇
    • 评论:27条
    联系我
    QQ:315253566
    最新评论