BestCoder——59
http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=640
第一题:给一堆书的序列 每次操作只能将书从中间移到最上面 求最少移动多少次 使得有序
只有19本书
怎么暴力怎么来
可以观察出 一本书最多被移动一次 不然移动就不存在意义了
ID最大的书是不被移动的 so 倒着查询有多少本是不被移动的就行了
#include<iostream>
#include<cstdio>
#include<cstring> using namespace std; int a[];
int main()
{
int Cas;
scanf("%d",&Cas);
while (Cas--)
{
int n;
scanf("%d",&n);
for (int i = ;i<=n;i++)
scanf("%d",&a[i]);
for (int i = n;i>=;i--)
{
if (a[i] == n)
n--;
}
printf("%d\n",n);
}
return ;
}
代码君
第二题:求最多的分数
sum = a[i] - b[i]*(耗费的时间)
贪心 加 搜索
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; typedef long long LL;
const int maxn = + ;
struct node{
int a,b,c;
}p[maxn]; bool cmp(node t1,node t2)
{
return (LL)t1.c*t2.b < (LL)t2.c*t1.b;
}
int dp[maxn];
int main()
{
int Cas;
scanf("%d",&Cas);
while (Cas--)
{
int n,t;
scanf("%d%d",&n,&t);
for (int i = ;i<=n;i++)
{
scanf("%d%d%d",&p[i].a,&p[i].b,&p[i].c); }
sort(p+,p+n+,cmp); memset(dp,,sizeof(dp));
for (int i = ;i<=n;i++)
{
for (int j = t;j>=p[i].c;j--)
{
dp[j] = max(dp[j],dp[j-p[i].c] + (p[i].a - p[i].b * j));
}
}
int ans = ;
for(int i = ; i <= t; i++) ans = max(ans, dp[i]);
printf("%d\n", ans); }
return ;
}
代码
第四题: 判断一个得分序列是否有效
https://en.wikipedia.org/wiki/Tournament_(graph_theory)#Score_sequences_and_score_sets
代码是看别人的 以后就直接用了(以后应该也没有这种题了)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
using namespace std; #define maxn 50005
int n,x[maxn];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<n;i++) scanf("%d",&x[i]);
sort(x,x+n);
int sum1=;
int sum2=;
bool sign=;
for(int i=;i<n;i++)
{
sum1+=x[i];
sum2+=i;
if(sum1<sum2) sign=;
}
if(sum1!=sum2) sign=;
if(sign) puts("It seems to have no problem.");
else puts("The data have been tampered with!");
}
}
代码
BestCoder——59的更多相关文章
- BestCoder Round 59 (HDOJ 5500) Reorder the Books
Problem Description dxy has a collection of a series of books called “The Stories of SDOI”,There are ...
- HDU5501/BestCoder Round #59 (div.2)The Highest Mark dp+贪心
The Highest Mark 问题描述 2045年的SD省队选拔,赛制和三十年前已是完全不同.一场比赛的比赛时间有 tt 分钟,有 nn 道题目. 第 ii 道题目的初始分值为 A_i(A_i \ ...
- BestCoder Round #59 (div.2) B. Reorder the Books 想法题
Reorder the Books 问题描述 dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n\leq 19)n(n≤19)本,每本书有一个编号,从 ...
- hdu 5667 BestCoder Round #80 矩阵快速幂
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- hdu5634 BestCoder Round #73 (div.1)
Rikka with Phi Accepts: 5 Submissions: 66 Time Limit: 16000/8000 MS (Java/Others) Memory Limit: ...
- 编写高质量代码:改善Java程序的151个建议(第4章:字符串___建议56~59)
建议56:自由选择字符串拼接方法 对一个字符串拼接有三种方法:加号.concat方法及StringBuilder(或StringBuffer ,由于StringBuffer的方法与StringBuil ...
- C#得到某月最后一天晚上23:59:59和某月第一天00:00:00
项目需求: 某学校订单截止操作时间的上一个月最后一天晚上23:59:59 为止所有支付的订单统计: 代码: /// <summary> /// 通过学校和截止时间得到订单 /// < ...
- Bestcoder#5 1002
Bestcoder#5 1002 Poor MitsuiTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
- BestCoder Round #80 1002
HDU 5666 Segment 题意:给你条斜率为-1,常数项为q(q为质数)的直线,连接原点与直线上整数格点,问你在有多少个格点在形成的无数个三角形内,而不在线段上,结果对P取模. 思路:best ...
随机推荐
- Redis实践操作之—— keyspace notification(键空间通知)
一.需求分析: 设置了生存时间的Key,在过期时能不能有所提示? 如果能对过期Key有个监听,如何对过期Key进行一个回调处理? 如何使用 Redis 来实现定时任务? 二.序言: 本文所说的定时任务 ...
- SAP 批量查看凭证更改记录
1,在凭证上点击环境->凭证变更 查找.2,通过运行程序 SE38:RSSCD1TS 根据对象类.对象标识查找. 3,SE16N/SE16/SE11查看标准表,CDHDR(更改凭证抬头),CDP ...
- amd64_or_ia64?
amd64 网上资料: 1. IA64是intel推出的架构,AMD64是AMD推出的.IA64不兼容原有的32位x86架构指令集,后来被证明这种做法是不成功的,于是Intel发展处IA64e架构,对 ...
- 08 高效的SQL
编写高效 SQL 需要以下知识 有关所查询内容的物理组织的知识 数据库能做什么的知识, 例如: 如果你不知道跳跃扫描索引及其用途, 那么你可能会看着模式说”索引丢了” SQL 所有错综复杂的知识 对目 ...
- apiCloud中图片裁剪模块FNImageClip的使用
思路 1.获取需裁剪图片的地址 2.跳转到裁剪页面 3.裁剪成功返回新图片地址 4.替换原有图片地址 增加修饰和事件 str += '<li class="tu image" ...
- 下载Android 5.0源码(附源码)
下载方法见我的另一篇博客:http://blog.csdn.net/maosidiaoxian/article/details/41680769 2014-12-24更新:5.0.1源码已上传. 这次 ...
- hdu5787(数位dp)
基础的数位dp,才发现今天才终于彻底搞懂了数位dp... // // main.cpp // hdu5787.1 // // Created by New_Life on 16/8/10. // Co ...
- 【官方方法】xcode7免证书真机调试
[官方方法]xcode7免证书真机调试 步骤比较简单,我就简单总结一下. 1. 进入xcode,菜单栏选择xcode –> preferences (快捷键 command + ,)在Accou ...
- LayoutParams使用
LayoutParams继承于Android.View.ViewGroup.LayoutParams. LayoutParams相当于一个Layout的信息包,它封装了Layout的位置. ...
- sizeof和strlen()的区别
二者有本质上的区别 从定义可以知道sizeof只是一个operator,而strlen()则是定义一个定义在<string.h>中的函数;所以sizeof(string)是在计算strin ...