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的更多相关文章

  1. 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 ...

  2. HDU5501/BestCoder Round #59 (div.2)The Highest Mark dp+贪心

    The Highest Mark 问题描述 2045年的SD省队选拔,赛制和三十年前已是完全不同.一场比赛的比赛时间有 tt 分钟,有 nn 道题目. 第 ii 道题目的初始分值为 A_i(A_i \ ...

  3. BestCoder Round #59 (div.2) B. Reorder the Books 想法题

    Reorder the Books 问题描述 dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n\leq 19)n(n≤19)本,每本书有一个编号,从 ...

  4. hdu 5667 BestCoder Round #80 矩阵快速幂

    Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536 ...

  5. hdu5634 BestCoder Round #73 (div.1)

    Rikka with Phi  Accepts: 5  Submissions: 66  Time Limit: 16000/8000 MS (Java/Others)  Memory Limit: ...

  6. 编写高质量代码:改善Java程序的151个建议(第4章:字符串___建议56~59)

    建议56:自由选择字符串拼接方法 对一个字符串拼接有三种方法:加号.concat方法及StringBuilder(或StringBuffer ,由于StringBuffer的方法与StringBuil ...

  7. C#得到某月最后一天晚上23:59:59和某月第一天00:00:00

    项目需求: 某学校订单截止操作时间的上一个月最后一天晚上23:59:59 为止所有支付的订单统计: 代码: /// <summary> /// 通过学校和截止时间得到订单 /// < ...

  8. Bestcoder#5 1002

    Bestcoder#5 1002 Poor MitsuiTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  9. BestCoder Round #80 1002

    HDU 5666 Segment 题意:给你条斜率为-1,常数项为q(q为质数)的直线,连接原点与直线上整数格点,问你在有多少个格点在形成的无数个三角形内,而不在线段上,结果对P取模. 思路:best ...

随机推荐

  1. Redis脚本插件之————执行Lua脚本示例

    Redis在2.6推出了脚本功能,允许开发者使用Lua语言编写脚本传到Redis中执行.使用脚本的好处如下: 1.减少网络开销:本来5次网络请求的操作,可以用一个请求完成,原先5次请求的逻辑放在red ...

  2. adb_亮屏

    来自:http://justonlypiano.blogspot.tw/2013/08/adbandroidandroid-phone-screen-off-via.html 更多内容请查看:http ...

  3. maven的仓库、生命周期与插件

    一.仓库 统一存储所有Maven项目共享的构建的位置就是仓库. 仓库分为本地仓库和远程仓库.远程仓库又分为中央仓库(中央仓库是Maven核心自带的远程仓库),伺服(另一种特殊的远程仓库,为节省宽带和时 ...

  4. JS---------->数组练习!

      var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0]; 要求将数组中的0项去掉,将不为0的值存入一个新的数组,生成新的数组 <!doctype htm ...

  5. 设置TextView下划线并响应点击事件(SpannableString)

    下面是一个20行的完整Demo代码:基本原理是使用一个SpannableString并设置其ClickableSpan来响应点击事件. TextView useInfo = (TextView) fi ...

  6. Nginx基本配置备忘

    原文:http://www.open-open.com/lib/view/open1482477873078.html Nginx 配置 在了解具体的Nginx配置项之前我们需要对于Nginx配置文件 ...

  7. 记录一下表格用poi的导出word

    也是网上找的代码http://53873039oycg.iteye.com/blog/2152009,但是横向合并单元格没成功.只能用很蠢的办法建立了好多table public void fillT ...

  8. 转:C++中Static作用和使用方法

    转自:http://blog.csdn.net/artechtor/article/details/2312766 1.什么是static?       static 是C++中很常用的修饰符,它被用 ...

  9. openSUSE 国内镜像和镜像使用帮助 (zhuan)

    https://my.oschina.net/u/2475751/blog/631036?p={{currentPage-1}} https://lug.ustc.edu.cn/wiki/mirror ...

  10. sql中out与output

    --SQLQuery Create By Faywool         create proc Proc_OutPutTest--创建 @numA int,--numA为存储过程的参数 @numB  ...