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. iOS - OC Struct 结构体

    1.结构体的定义与调用 // 定义结构体类型 // 结构体类型名为 MyDate1 struct MyDate1 { int year; int month; int day; }; // 定义结构体 ...

  2. mysql 聚集函数和分组

    1.sc表的内容如下:mysql> select * from sc order by sid asc;+----+-------+-----+-------+| ID | SID | CID ...

  3. Java 文件IO续

    文件IO续 File类    用来将文件和文件夹封装成对象 方便对文件和文件夹的属性信息进行操作    File对象可以作为参数传递给流的构造函数 Demo1 File的构造方法 public cla ...

  4. MyBatis——调用存储过程

    原文:http://www.cnblogs.com/xdp-gacl/p/4270352.html 一.提出需求 查询得到男性或女性的数量, 如果传入的是0就女性否则是男性 二.准备数据库表和存储过程 ...

  5. hdu5785(极角排序求所有锐角钝角个数)

    做法很显然,求出所有的锐角和钝角就能求出有多少个锐角三角形了. 我用了愚钝的方法,写了两三个小时... 看了下别人简单的代码.学习了下做法. sort(temp+,temp+cnt+);//排序 Fo ...

  6. linux优先级、性能监控指令

    一.优先级 优先级的值=优先系数+nice值     优先系数由系统内核决定,不可更改 nice值可以手动更改,范围是 -20~19 优先级的值越低,优先级越高:优先级的值越高,优先级越低. 所以想调 ...

  7. 在linux上搭建本地yum源

    准备yum仓库的光盘镜像IOS文件: 设置光驱加载本地磁盘的yum仓库的光盘镜像文件: 在linux的命令行输入setup命令打开设置窗口,选择"System Service": ...

  8. 抓包工具Fidder设置(移动端抓包)

    1.下载安装fiddler,下载链接:http://fiddler2.com/get-fiddler(我用的是免安装的fiddler2) 2.设置fiddler 打开Fiddler,     Tool ...

  9. 【CITE】 C#中实现拖动无边框Form窗体

    首先建一个Windows应用程序 将Form1的 FormBorderStyle属性设置为None 主要是在Form1窗体触发三个事件:Form4_MouseDown,Form4_MouseMove, ...

  10. hashtable 实现

    #include <stdlib.h> #include <stdio.h> #include <string.h> typedef struct _hashnod ...