BestCoder Round #91
来源:互联网 发布:通过网络被骗的案例 编辑:程序博客网 时间:2024/05/18 01:29
Lotus and Characters
Accepts: 150
Submissions: 897
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 262144/131072 K (Java/Others)
问题描述
Lotus有n种字母,给出每种字母的价值以及每种字母的个数限制,她想构造一个任意长度的串。定义串的价值为:第1位字母的价值*1+第2位字母的价值*2+第3位字母的价值*3……求Lotus能构造出的串的最大价值。(可以构造空串,因此答案肯定≥0)
输入描述
第一行是数据组数T(0≤T≤1000)。对于每组数据,第一行一个整数n(1≤n≤26),接下来n行,每行2个整数vali,cnti(∣vali∣,cnti≤100),分别表示第i种字母的价值和个数限制。
输出描述
对于每组数据,输出一行一个整数,表示答案。
输入样例
225 16 23-5 32 11 1
输出样例
355
水题--有hack点--
1
2
-2 2
1 3
代码:
#include<stdio.h>#include<string>#include<stack>#include<queue>#include<math.h>#include<string.h>#include<algorithm>using namespace std;#define LL long longLL gcd(LL a, LL b){ if (a%b==0) return b; return gcd(b,a%b);}struct node{ int a,b;}pp[30];bool cmp(node x, node y){ return x.a<y.a;}int main(){ int n,t; scanf("%d",&t); while (t--) { scanf("%d",&n); for (int i=0;i<n;i++) scanf("%d%d",&pp[i].a,&pp[i].b); sort(pp,pp+n,cmp); int ans=0,lp=1,he=0; for (int i=n-1;i>=0;i--) { for (int j=0;j<pp[i].b;j++) { if (pp[i].a+he>0) { ans+=he+pp[i].a; he+=pp[i].a; } } } printf("%d\n",ans); } return 0;}
Lotus and Horticulture
Accepts: 91
Submissions: 641
Time Limit: 4000/2000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
问题描述
这几天Lotus对培养盆栽很感兴趣,于是她想搭建一个温室来满足她的研究欲望。Lotus将所有的n株盆栽都放在新建的温室里,所以所有盆栽都处于完全相同的环境中。每一株盆栽都有一个最佳生长温度区间[l,r],在这个范围的温度下生长会生长得最好,但是不一定会提供最佳的研究价值(Lotus认为研究发育不良的盆栽也是很有研究价值的)。Lotus进行了若干次试验,发现若第i株盆栽的生长温度适宜,可以提供ai的研究价值;若生长温度超过了适宜温度的上限,能提供bi的研究价值;若生长温度低于适宜温度的下限,则能提供ci的研究价值。现在通过试验,Lotus已经得知了每一株盆栽的适宜生长温度范围,也知道了它们的a、b、c的值。你需要根据这些信息,给温室选定一个温度(这个温度可以是任意实数),使得Lotus能获得的研究价值最大。
输入描述
多组数据,第一行一个整数T表示数据组数每组数据第一行一个整数n∈[1,50000],表示盆栽数量接下来n行每行五个整数li,ri,ai,bi,ci∈[1,109],意义如上所述
输出描述
每组数据输出一行一个整数表示答案
输入样例
155 8 16 20 1210 16 3 13 138 11 13 1 117 9 6 17 52 11 20 8 5
输出样例
83
伪离散化--
-.-开始没有考虑左边界和右边界----只是直接跳过边界---终判GG
代码:
#include<stdio.h>#include<string>#include<stack>#include<queue>#include<math.h>#include<string.h>#include<algorithm>using namespace std;#define LL __int64struct node{ LL a,b,c;int l,r;}pp[60000];struct nn{ int shu,hao;}kk[120000];bool cmp1(nn x,nn y){ if (x.shu!=y.shu) return x.shu<y.shu; return x.hao%2<y.hao%2;}int main(){ int n,t; scanf("%d",&t); while (t--) { scanf("%d",&n); int lp=0; LL ans=0,da=0; for (int i=0;i<n;i++) { scanf("%d%d%I64d%I64d%I64d",&pp[i].l,&pp[i].r,&pp[i].a,&pp[i].b,&pp[i].c); kk[lp].hao=lp;kk[lp++].shu=pp[i].l;kk[lp].hao=lp;kk[lp++].shu=pp[i].r; ans+=pp[i].c; } da=ans; sort(kk,kk+lp,cmp1); int kp=0,hh,xun; for (int i=0;i<lp;i++) { xun=1; if (kk[i].hao%2==0) { xun=1; while (xun) { hh=kk[i].hao/2; ans+=pp[hh].a-pp[hh].c;xun=0; if (i!=lp-1&&kk[i+1].shu==kk[i].shu&&kk[i+1].hao%2==kk[i].hao%2) { i++;xun=1; } } if (ans>da) da=ans; } else { xun=1; while (xun) { hh=kk[i].hao/2; ans+=pp[hh].b-pp[hh].a;xun=0; if (i!=lp-1&&kk[i+1].shu==kk[i].shu&&kk[i+1].hao%2==kk[i].hao%2) { i++;xun=1; } } if (ans>da) da=ans; } } printf("%I64d\n",da); } return 0;}
0 0
- BestCoder Round #91
- BestCoder Round #91
- BestCoder Round #91【思维】
- BestCoder Round #91(前两题)
- BestCoder Round #91 hack大战
- BestCoder Round #3 BestCoder Sequence
- bestcoder round #1
- BestCoder round #1
- BestCoder Round #1
- 【索引】BestCoder Round #2
- BestCoder Round #2
- 【索引】BestCoder Round #3
- BestCoder Round #3
- BestCoder Round #3 小记
- BestCoder Round #4 题解
- BestCoder Round #6
- BestCoder Round #8
- Bestcoder Round #9
- KMP算法
- Jquery——显示和隐藏
- 独立开发 一个社交 APP 的架构分享
- JDBCREPO_0021:Given link name is in use - Name in use:
- java 等待所有线程执行完毕
- BestCoder Round #91
- 使用JavaMailSenderImpl实现Email发送
- 前后端对请求参数排序
- vs为QT程序添加icon图标
- spring cloud-将spring boot服务注册到Eureka Server上
- 自定义第三方包
- 微信红包的坑~参数详解和密钥的坑
- vcf通讯录格式解析
- 自适应屏幕的后台系统?