2017百度之星资格赛 1003:度度熊与邪恶大魔王(DP)
.navbar-nav > li.active > a {
background-image: none;
background-color: #058;
}
.navbar-inverse #navbar > .navbar-nav > li > a:hover,
.navbar-inverse #navbar > .navbar-nav > li > a:focus {
background-image: none;
background-color: #069;
}
.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .open > a:hover,
.navbar-inverse .navbar-nav > .open > a:focus {
background-image: none;
background-color: #058;
}
.navbar-brand {
padding: 0;
}
.navbar-inverse .dropdown-menu {
background-color: #0696cb;
}
.navbar-inverse .dropdown-menu > li > a:hover,
.navbar-inverse .dropdown-menu > li > a:focus {
background-image: none !important;
background-color: #058 !important;
}
.navbar-brand > img {
height: 48px;
width: auto;
}
.footer {
width: 100%;
padding: 5px 20px;
margin-top: 20px;
border-top: 1px solid #e7e7e7;
background-color: #F0F0F0;
text-align: center;
}
.table-center th, .table-center td {
text-align: center;
}
.table-middle th, .table-middle td {
vertical-align: middle !important;
}
.table .table {
background-color: inherit;
}
.operate > a + a {
margin-left: 10px;
}
.form-inline {
margin-bottom: 10px;
}
.pull-left > ul.pagination, .pull-right > ul.pagination {
margin: 0;
}
.problem-widget {
margin-top: 30px;
}
.problem-widget-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 5px;
color: #333;
}
.problem-widget pre {
padding: 0;
margin: 0;
font-size: 13px;
line-height: 1.42857143;
color: #333;
word-break: break-word;
white-space: pre-wrap;
background-color: transparent;
border: none;
overflow: visible;
}
.problem-widget-content {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 14px;
line-height: 1.42857143;
color: #333;
word-break: break-word;
background-color: #f5f5f5;
border: 1px solid #ccc;
}
.clipboard {
position: relative;
}
.clipboard > .copy {
display: none;
float: right;
padding: 3px 6px;
}
.clipboard:hover > .copy {
display: inline-block;
}
.problem-footer {
text-align: center;
font-size: 16px;
font-weight: bold;
margin-top: 20px;
}
.problem-footer .btn + .btn {
margin-left: 40px;
}
img.country-flag {
width: 42px;
height: 27px;
}
#status-form input {
width: 100px;
}
#status-form input[type="submit"] {
padding: 5px;
width: 50px;
}
.status-nav {
text-align: center;
}
.status-nav > a + a {
margin-left: 30px;
}
.required {
margin-right: -11px;
padding-left: 4px;
color: red;
}
.required::after {
content: '*';
}
.label-text {
padding-top: 7px;
margin-bottom: 0;
}
#check-code {
text-align: center;
padding: 7px 0;
}
.form-error {
color: #d00;
font-size: 1.2em;
}
.problem-status {
width: 70px;
display: inline-block;
}
.problem-status-number {
font-size: .8em;
color: #cc0000;
}
.form-group > .input-group + .input-group {
margin-top: 5px;
}
#contest-info {
font-size: 1.1em;
}
#contest-info p {
margin-bottom: 5px;
}
#contest-info h2 {
font-size: 24px;
}
.text-red {
color: #f00;
}
.text-green {
color: #080;
}
.text-orange {
color: #f90;
}
.text-purple {
color: #808;
}
#contest-list img {
width: 24px;
}
#contest-list img {
margin-left: 8px;
}
#contest-list .contest-time {
font-size: 10px;
}
.no-data {
font-family: "times new roman", serif;
margin-top: -20px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-top: none;
font-size: 64px;
color: #aaa;
text-align: center;
padding: 80px;
}
.no-body-data {
font-family: "times new roman", serif;
border-top: 2px solid #ccc;
font-size: 64px;
color: #aaa;
text-align: center;
padding: 80px;
}
.panel .nav-tabs {
margin-bottom: 15px;
}
.badge-statistic {
font-size: 15px;
padding: 3px 12px;
background-color: green;
}
#contest-ranklist .ranklist-problemid {
font-size: .8em;
padding-top: 2px;
padding-bottom: 2px;
}
#contest-ranklist .ranklist-problem {
font-size: .8em;
padding-top: 2px;
padding-bottom: 2px;
}
#contest-ranklist .ranklist-problem > .text-green {
font-weight: bold;
}
.countdown {
display: inline-block;
}
.pending {
padding: 50px;
font-size: 36px;
text-align: center;
}
.countdown > span {
padding: 2px;
border: 1px solid #ddd;
border-radius: 2px;
background: #f8f8f8;
}
#concern-team {
margin-top: -10px;
margin-bottom: 5px;
}
.form-footer {
text-align: center;
}
.form-footer > .btn {
min-width: 80px;
}
.form-footer > .btn + .btn {
margin-left: 60px;
}
.topic-reply {
margin: 0;
padding: 5px;
}
.topic-reply > div > img {
width: 100%;
height: auto;
max-height: 80px;
max-width: 80px;
}
.topic-reply:hover {
background-color: #fcfcfc;
}
.topic-reply + .topic-reply {
margin-top: 10px;
}
.topic-main {
border: 1px solid #ccc;
border-radius: 4px;
padding: 0;
}
.topic-main:before, .topic-main:after {
position: absolute;
top: 11px;
left: -16px;
right: 100%;
width: 0;
height: 0;
display: block;
content: " ";
border-color: transparent;
border-style: solid solid outset;
pointer-events: none;
}
.topic-main:before {
border-right-color: #ccc;
border-width: 8px;
}
.topic-main:after {
border-width: 7px;
border-right-color: #eee;
margin-top: 1px;
margin-left: 2px;
}
.topic-reply-author {
background-color: #eee;
border-bottom: 1px solid #ccc;
padding: 8px;
}
.topic-reply-title {
font-size: 17px;
padding: 5px 10px 0;
}
.topic-reply-content {
padding: 10px;
word-break: break-word;
}
.check-code > input {
position: relative;
}
.check-code > img {
position: absolute;
z-index: 100;
right: 5px;
height: 36px;
top: 5px;
}
#contest-info, #problem-info {
margin-bottom: 20px;
}
#contest-info h1, #problem-info h1 {
margin-right: 30px;
display: inline-block;
color: #333;
}
#contest-info .status-pending, #contest-info .status-runing, #contest-info .status-ended {
border-radius: 4px;
padding: 3px 6px;
color: #fff;
}
#contest-info .status-pending {
background-color: #5bc0de;
}
#contest-info .status-runing {
background-color: green;
}
#contest-info .status-ended {
background-color: gray;
}
#contest-info #current-time {
margin-left: 10px;
}
#problem-info .problem-statistic {
display: inline-block;
margin-right: 40px;
}
.level0 {
color: #000 !important;
}
.level1 {
color: #9E9E9E !important;
}
.level2 {
color: #8BC34A !important;
}
.level3 {
color: #4CAF50 !important;
}
.level4 {
color: #00BCD4 !important;
}
.level5 {
color: #3F51B5 !important;
}
.level6 {
color: #9C27B0 !important;
}
.level7 {
color: #FF9800 !important;
}
.level8 {
color: #F06292 !important;
}
.level9 {
color: #FF0000 !important;
}
.link-above-table {
margin-bottom: 5px;
}
#source-modal > .modal-lg {
width: 604px;
margin: 10px auto;
}
#source-modal .modal-body {
padding: 0;
}
#source-modal .modal-body > pre {
margin: 0;
}
#room {
margin-bottom: 10px;
}
#room .my-room {
font-weight: bold;
color: green;
}
#contest-pending {
font-size: 2em;
text-align: center;
padding: 50px;
border: 1px solid #008cba;
border-radius: 4px;
}
.table > thead > tr > th, .table > tbody > tr > td {
vertical-align: middle;
}
#navbar .countdown {
margin-top: 16px;
color: #fff;
}
#navbar .countdown > span {
border-color: #069;
background-color: #07a
}
.clock, .countdown {
display: none;
}
img.ac-tired {
margin-left: 15px;
}
#data-text{
height: 500px;
}
#contest-hackstatus > tbody {
display: none;
}
#contest-hackstatus > tbody:first-child {
display: block;
}
#show-all-hackstatus {
display: none;
}
#global-message, #contest-message {
display: none;
}
.form-group .addon > select {
display: inline-block;
width: 70%;
}
.form-group .addon > select + span {
font-size: 1.6em;
vertical-align: middle;
margin-left: 2px;
}
.form-horizontal .form-group .row {
margin: 0;
}
.form-horizontal .form-group .row > div {
padding: 0;
}
fieldset + fieldset {
margin-top: 20px;
}
div.address #address {
margin-top: 5px;
}
.nav-tabs {
margin-bottom: 10px;
}
table.contest-register td {
border: none !important;
}
table.contest-register tr > td:first-child {
width: 40%;
text-align: right;
padding-right: 10%;
}
.h1-align {
height: 69px;
padding-top: 25px;
padding-bottom: 10px;
text-align: right;
}
.h3-align {
height: 56px;
padding-top: 10px;
padding-bottom: 10px;
text-align: right;
}
@media (max-width:768px) {
.h1-align, .h3-align {
text-align: left;
}
}
.form-tooltip {
padding-top: 8px;
padding-left: 0;
margin-left: -8px;
}
.mb10 {
margin-bottom: 10px;
}
table#contest-time {
margin-top: 6px;
}
table#contest-time td {
padding: 2px 5px 0 0;
}
.markdown {
white-space: pre-wrap;
word-break: break-word;
}
.markdown.marked {
white-space: normal;
}
#solutions {
border: 2px solid #008cba;
box-shadow: 4px 4px 8px #ccc;
}
#solutions > .solution {
padding: 10px;
}
#solutions > .solution + .solution {
border-top: 1px dashed #888;
}
#solutions > .solution > .solution-title span.status {
font-size: 18px;
margin-right: 4px;
}
#solutions > .solution > .solution-title > div.text-right {
padding: 5px 20px;
}
#solutions > .solution > .solution-provider {
font-size: 1.5em;
}
#solutions > .solution > .solution-bestcoder {
margin: 10px 0 0;
font-size: 1.5em;
}
#solutions > .solution > .solution-bestcoder > div {
white-space: nowrap;
}
#solutions > .solution > .solution-bestcoder > div > a {
color: white !important;
}
#solutions > .solution > .solution-bestcoder > .no1 {
background: red;
}
#solutions > .solution > .solution-bestcoder > .no2 {
background: orange;
}
#solutions > .solution > .solution-bestcoder > .no3 {
background: purple;
}
#solutions > .solution > .solution-body {
margin-top: 15px;
}
#system-message {
border: 1px solid #008cba;
padding: 8px;
margin-right: -15px;
}
#system-message > h3 {
color: #008cba;
text-align: center;
border-bottom: 1px solid #888;
margin: -5px -8px 8px;
padding: 5px;
}
#tops {
border: 1px solid #008cba;
margin-top: 20px;
margin-right: -15px;
}
#tops > h3 {
color: #008cba;
text-align: center;
border-bottom: 1px solid #888;
margin: 5px 0 0;
padding: 5px;
}
#tops > table {
margin-bottom: 0;
}
#weibo {
border: 1px solid #008cba;
margin-top: 20px;
margin-right: -15px;
}
#code-style {
float: right;
margin-right: 20px;
}
#hack-error {
color: #f00;
font-size: 1.2em;
float: left;
}
#message-box {
position: fixed;
right: 40px;
bottom: 20px;
width: 500px;
max-height: 250px;
overflow-y: auto;
}
#message-box > li.list-group-header {
font-size: 1.2em;
font-weight: bold;
border-bottom: 3px solid #008cba;
color: #008cba;
padding: 10px;
}
#message-box > li > .time {
float: right;
}
.link-icon:hover, .link-icon:active, .link-icon:focus {
text-decoration: none;
}
.link-icon {
margin-left: 10px;
}
#profile-heading {
margin: 0;
padding: 10px;
background-color: #f2fcff;
}
#profile-heading .bigggger {
font-size: 4em;
padding: 20px 40px 20px 5px;
color: #000;
}
#profile-school > a {
font-size: 1.4em;
margin-left: 5px;
}
#profile-motto {
font-size: 1.2em;
color: #444;
font-style: italic;
}
.fa-spin, .fa-pulse {
vertical-align: middle;
margin-left: 5px;
font-size: 16px;
}
.badge a {
color: #fff;
}
#rating-chart-wrapper {
min-width: 0px;
overflow: auto;
}
#rating-chart {
min-width: 768px;
}
.twitter-typeahead {
display: block !important;
}
.typeahead {
background-color: #fff;
}
.typeahead:focus {
border: 2px solid #0097cf;
}
.tt-query {
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.tt-hint {
color: #999
}
.tt-menu {
width: 100%;
margin: 0 0 12px;
padding: 8px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
box-shadow: 0 5px 10px rgba(0,0,0,.2);
}
.tt-suggestion {
padding: 3px 20px;
font-size: 18px;
line-height: 24px;
}
.tt-suggestion:hover {
cursor: pointer;
color: #fff;
background-color: #0097cf;
}
.tt-suggestion.tt-cursor {
color: #fff;
background-color: #0097cf;
}
.tt-suggestion p {
margin: 0;
}
img{
max-width: 100%;
}
.index-banner {
display: block;
margin: 0 -15px;
}
.index-banner > img {
width: 100%;
}
-->
度度熊与邪恶大魔王
1 2
3 5
7 10
6 8
1 2
3 5
10 7
8 6
6
18
/*
ans[i][j][b]表示防御力为b的怪物
表示用前i种技能,造成恰好j的伤害消耗的最小晶石
ans[i][j][b]=min{ans[i-1][j-x*(p[i]-b)]+x*k[i]}
x表示第i种技能取x个(0<=x*(p[i]-b)<=j)
优化:http://blog.csdn.net/wumuzi520/article/details/7014830
ans[i][j][b]=min(ans[i-1][j][b],ans[i][j-(p[i]-b)][b]+k[i]【j>=p[i]-b】)
=>ans[j][b]=min(ans[j][b],ans[j-(p[i]-b)][b]+k[i] **i从小到大
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n,m;
LL maxb,maxp,bx,maxa;
LL a[],b[];
LL ans[][];
LL k[],p[],ans1;
int main()
{
LL i,j,t,ze=(long long);
while(scanf("%lld%lld",&n,&m)==)
{
maxb=;maxp=;maxa=;
for(i=;i<=n;i++)
{
scanf("%lld%lld",&a[i],&b[i]);
maxb=max(maxb,b[i]);
maxa=max(maxa,a[i]);
}
for(i=;i<=m;i++)
{
scanf("%lld%lld",&k[i],&p[i]);
maxp=max(maxp,p[i]);
}
maxa=max(maxa,maxp);
/*
去掉以上这句,会让类似
1 1
45 10
4164 327
的数据得出错误结果
*/
if(maxb>=maxp)
{
printf("-1\n");
continue;
}
memset(ans,0x3f,sizeof(ans));
memset(ans[],,sizeof(ans[]));
for(bx=;bx<=maxb;bx++)
{
for(i=;i<=m;i++)
for(j=max(ze,p[i]-bx);j<=*maxa;j++)
// {
//if(j>=p[i]-bx)
ans[j][bx]=min(ans[j][bx],ans[j-p[i]+bx][bx]+k[i]);
// }
t=0x3f3f3f3f;
for(j=*maxa;j>=;j--)
{
t=min(t,ans[j][bx]);
ans[j][bx]=min(ans[j][bx],t);
}
}
ans1=;
for(i=;i<=n;i++)
ans1+=ans[a[i]][b[i]];
printf("%lld\n",ans1); }
return ;
}
2017百度之星资格赛 1003:度度熊与邪恶大魔王(DP)的更多相关文章
- 百度之星 资格赛 1003 度度熊与邪恶大魔王 dp(背包)
度度熊与邪恶大魔王 Accepts: 1141 Submissions: 6840 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 3 ...
- 百度之星资格赛 1003 度度熊与邪恶大魔王(二维dp)
分析 挺好的一道题 dp[i][j]表示打败i颗血j防御力的怪兽需要的最少宝石数 然后就好了,复杂度\(O(n+m*1000*10)\) #include <bits/stdc++.h> ...
- HDU 6118 2017百度之星初赛B 度度熊的交易计划(费用流)
度度熊的交易计划 Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU - 6113 2017百度之星初赛A 度度熊的01世界
度度熊的01世界 Accepts: 967 Submissions: 3064 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 327 ...
- 度度熊与邪恶大魔王 DP | 完全背包
Problem Description 度度熊为了拯救可爱的公主,于是与邪恶大魔王战斗起来. 邪恶大魔王的麾下有n个怪兽,每个怪兽有a[i]的生命值,以及b[i]的防御力. 度度熊一共拥有m种攻击方式 ...
- 百度之星资格赛 1004 度度熊的午饭时光(01背包+最小序号和+字典序+有bug)
分析 首先声明一下,我的代码有漏洞的,求大神给个正确代码 思路如下: 首先做一遍01背包记录路径并求出最大总分,令path[i][j]表示第i个物品包含在dp[j]的求值过程中.再逆序枚举money, ...
- hdu 6082 度度熊与邪恶大魔王(2017"百度之星"程序设计大赛 - 资格赛 )
度度熊与邪恶大魔王 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- 2017"百度之星"程序设计大赛 - 资格赛-度度熊与邪恶大魔王(dp+后缀最小值)
度度熊与邪恶大魔王 思路:由于防御和血量的范围很小,所以暴力枚举出对于每种防御造成的每种伤害所需的最小花费,最后只需在伤害大于等于血量的情况下再找到最小花费(这个只需要后缀最小值预处理一下就可以了) ...
- 模拟 2015百度之星资格赛 1003 IP聚合
题目传送门 /* 模拟水题,排序后找出重复的ip就可以了 */ #include <cstdio> #include <iostream> #include <algor ...
随机推荐
- 【健康生活】Google、百度之间的选择
没有什么技术性的分析,仅仅是个人吐槽而已. 一般人遇到问题就会说一句"百度一下",说实话,百度在中国推广的真的非常不错,可谓是家喻户晓,搜索个八卦新闻,小文章,小电影什么的的确非常 ...
- 【bzoj2761】【JLOI2011】【不反复数字】【平衡树】
Description 给出N个数,要求把当中反复的去掉.仅仅保留第一次出现的数. 比如,给出的数为1 2 18 3 3 19 2 3 6 5 4.当中2和3有反复.去除后的结果为1 2 18 3 1 ...
- centos笔记-安装特定版本的mysql
centos6的yum默认安装的mysql是5.1版, 如果要安装5.6.16 版,有三个办法 1.yum方式, 这个方式的好处是通过yum安装卸载都很方便,坏处是版本无法详细制定,比如官方版本yum ...
- [rabbitmq-discuss] Exactly Once Delivery
[rabbitmq-discuss] Exactly Once Delivery http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2010-A ...
- JavaScript算法题(一) && 数组reduce使用
可参考Array.reduce用法 1. 请编写getMissingElement函数,返回给定数组中缺少的元素(数组里的元素为0~9,只会缺失一个). Example: getMissingElem ...
- Linux时间子系统之三:时间的维护者:timekeeper【转】
本文转载自:http://blog.csdn.net/droidphone/article/details/7989566 本系列文章的前两节讨论了用于计时的时钟源:clocksource,以及内核内 ...
- html5--6-14 CSS3中的颜色表示方式
html5--6-14 CSS3中的颜色表示方式 实例 每个参数 (red.green 以及 blue) 定义颜色的强度,可以是介于 0 与 255 之间的整数,或者是百分比值(从 0% 到 100% ...
- 深入浅出Oracle学习笔记:Undo
undo的作用是:解决oracle多用户读写一致性,以及操作可撤销或者回滚. 1.undo表空间是从10g开始进行自动管理的,几个参数如下: undo_management:回滚段手动管理还是自动管理 ...
- Intel® Media Server Studio Support
复制自网址:https://software.intel.com/en-us/intel-media-server-studio-support/code-samples Code Samples M ...
- [转]Python+Selenium之expected_conditions:各种判断(上)
原文地址: https://www.jianshu.com/p/f3189f1951cc 其他类似文章: https://www.cnblogs.com/yuuwee/p/6635652.html h ...