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. lab_c!

    #include<stdio.h> hi() { printf("hello world!\n"); } int main() { hi(); int i = hi() ...

  2. CentOS6.4_常用命令

    1. 查看本机是否安装了 xxx软件,以及 xxx软件 的版本信息等: rpm -qa |grep  xxx(xxx代表软件名) 2. rpm -ivh 要安装的rpm文件包 3. 不care依赖项的 ...

  3. Google账户_GooglePlay_关联

    PS:这过程叫一个折腾...穷逼的无奈啊... 1. 1.1. 网上搜到说,安装 google play & google框架服务,手机需要root,没去证实这个事情... 用了之前的 And ...

  4. 一次tomcat服务器被入侵解决办法

    突然tomcat目录下莫名其妙的多了几个war文件,里面内容只有一个index.jsp,打开控制台发现多了几个应用,我可以确定不是我部署上去的,顺着应用访问竟然看到了

  5. 多列布局 css3 column属性

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  6. Android 数据库升级解决方案

    转自:http://blog.csdn.net/leehong2005/article/details/9128501 请考虑如下情况: 在数据库升级时,不同版本的数据库,他们定义的表结构完全可能是不 ...

  7. Android_SDK的常用命令

    一.配置环境变量 要想使用这些命令,就必须先配置环境变量.  将android-sdk-windows目录下的platform-tools目录和tools目录配置到path环境变量中 二.adb命令 ...

  8. [转]Android 使用Fragment界面向下跳转并一级级返回

      1.首先贴上项目结构图: 2.先添加一个接口文件BackHandledInterface.java,定义一个setSelectedFragment方法用于设置当前加载的Fragment在栈顶,主界 ...

  9. map 后 PE 蓝屏原因专题讨论(e820cycles参数)

    map 后 PE 蓝屏原因专题讨论(e820cycles参数)http://bbs.znpc.net/thread-6182-1-5.html不点发表于 2011-12-8 11:42:31 大家知道 ...

  10. MySQL redo lock 死锁问题排查 & 解决过程

    版权声明:本文由张青林原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/181 来源:腾云阁 https://www.qclo ...