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 - NSURLSession 网络请求

    前言 NS_CLASS_AVAILABLE(NSURLSESSION_AVAILABLE, 7_0) @interface NSURLSession : NSObject @available(iOS ...

  2. SQL 调优专题总结

    oracle 的优化器: oracle 有两种优化器:基于规则的优化器(rbo/rule based optimizer)和基于代价的优化器(cbo/cost based optimizer). 有时 ...

  3. Python学习笔记9—文件

    打开文件

  4. centos7 php7 安装composer时Failed to decode zlib stream解决办法

    1 下载安装脚本 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 2 运行安装脚 ...

  5. mysql 建立索引场合及索引使用

    索引建立场合: ① where后边字段 适合建立索引 ② order by 排序字段适合建立索引 ③ 索引覆盖 即 所要查询的字段本身就是索引 直接在索引中查询数据. 例如 select name,a ...

  6. ltib学习抄录

    linux -- LTIB学习笔记 一 安装篇二 运行篇三 修改工具包 四 编译新的内核 ---------相关资料------------------------------------------ ...

  7. foundation系列

    1如何将布尔值转为OC对象?  1把 BOOL 值包装到 NSNumber中: NSNumber *boolNumber = [NSNumber numberWithBool:YES]  2获取BOO ...

  8. karma+angular

    下面的介绍以karma能正常运行为前提,看karma系列文章:http://www.cnblogs.com/laixiangran/tag/Karma/ 目录结构 步骤 安装 npm install ...

  9. 微信小程序初体验(上)

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

  10. 用NAN简化Google V8 JS引擎的扩展

    通过C++扩展Google V8 JS引擎的文章很多,Google V8 JS带的例子也容易明白.但是大部分文章都是Hello World型的,真正使用时发现处处是坑.扩展V8最经典的例子就是node ...