【比赛链接】

cid=608">clikc here~~

ps:真是wuyu~~做了两小时。A出两道题,最后由于没加longlong所有被别人hack掉!,最后竟然不知道hack别人不成功也会掉分。还一个劲的hack 别人的代码,昨天真是个悲催的比赛,~~~~(>_<)~~~~,以下弱弱献上代码~~

1002比1001还简单~~

1002  Senior's Gun

/*
BestCoder Round #47
1002 Senior's Gun */
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std; #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
typedef long long LL;
typedef unsigned long long LLU;
typedef double db; const int N =2*1e5+10;
int n,m,t,p,res,cnt;
LL ans,tmp;
int num[N];
int aa[N],bb[N];
char str[N];
bool vis[N]; int main()
{
scanf("%d",&t);
while (t--)
{
scanf("%d%d",&n,&m);
for (int i=1; i<=n; i++) scanf("%d",&aa[i]);
for (int i=1; i<=m; i++) scanf("%d",&bb[i]);
sort(aa+1,aa+n+1);
sort(bb+1,bb+m+1);
ans=0;
int j=n;
for (int i=1; i<=min(n,m); i++)
if(aa[j]>bb[i])
{
ans+=aa[j]-bb[i];
j--;
}
else break;
printf("%I64d\n",ans);
}
return 0;
}
Sample Input
1
2 2
2 3
2 2
Sample Output
1

1001 Senior's Array

/*
BestCoder Round #47
1001 Senior's Array */
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std; #define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
typedef long long LL;
typedef unsigned long long LLU;
typedef double db; const int N =2*1e4+10;
int n,m,t,p;
int aa[N],bb[N];
char str[N];
bool vis[N]; int main()
{
scanf("%d",&t);
while (t--)
{
scanf("%d%d",&n,&p);
rep(i,1,n) scanf("%d",&aa[i]);
LL ans=-1e9;
rep(i,1,n)
{
int tmp=aa[i];
aa[i]=p;
LL now=0;
rep(j,1,n)
{
now+=(1ll)*aa[j];
if(now>ans) ans=now;
if(now<0) now=0;
}
aa[i]=tmp;
}
printf("%I64d\n",ans);
}
return 0;
}
Sample Input
2
3 5
1 -1 2
3 -2
1 -1 2
Sample Output
8
2

BestCoder #47 1001&amp;&amp;1002的更多相关文章

  1. 简单几何(水)BestCoder Round #50 (div.2) 1002 Run

    题目传送门 /* 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 */ /***** ...

  2. BestCoder #88(1001 1002)

    Find Q Accepts: 392 Submissions: 780 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131 ...

  3. HDU 5280 BestCoder Round #47 1001:Senior's Array

    Senior's Array  Accepts: 199  Submissions: 944  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit ...

  4. HOJ 1001: A+B; 1002: A+B+C

    两道水题,用来熟悉 HOJ 的提交系统. 1001:输入两个整数 A, B (0 <= A,B <= 10),输出 A+B. #include <iostream> using ...

  5. Bestcoder #47 B Senior&#39;s Gun

    Senior's Gun Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tot ...

  6. BestCoder Round #68 (div.2) 1002 tree

    题意:给你一个图,每条边权值0或1,问每个点周围最近的点有多少个? 思路:并查集找权值为0的点构成的连通块. #include<stdio.h> #include<string.h& ...

  7. BestCoder Round #50 (div.1) 1002 Run (HDU OJ 5365) 暴力枚举+正多边形判定

    题目:Click here 题意:给你n个点,有多少个正多边形(3,4,5,6). 分析:整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可. #include ...

  8. bestcoder#23 1001 Sequence

    Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  9. ACM学习历程—HDU5586 Sum(动态规划)(BestCoder Round #64 (div.2) 1002)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5586 题目大意就是把一段序列里面的数替换成f(x),然后让总和最大. 首先可以计算出初始的总和,以及每 ...

随机推荐

  1. input标签不能设置height

    首先input是内联标签(inline) inline元素设置width.height属性无效 可以通过设置display:inline-block ,则内联标签可以设置width和height,但是 ...

  2. fzu 1753 质因数的应用

    Another Easy Problem Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  3. 页面之间传值的方法asp

    原文发布时间为:2008-06-02 -- 来源于本人的百度文章 [由搬家工具导入] asp.net页面间传值 今天学习中要在两个页面中传值,网上搜了一下,asp.net主要用到三个方法,前两个req ...

  4. linux内核栈与用户栈【转】

    转自:http://19880512.blog.51cto.com/936364/274610 最近linux内核的中断部分,总是被书里的栈弄晕,一会儿内核栈,一会儿用户栈的……很是崩溃,在网上goo ...

  5. 备份MySQL数据库的方法

    前言 我们试着想一想, 在生产环境中什么最重要?如果我们服务器的硬件坏了可以维修或者换新, 软件问题可以修复或重新安装, 但是如果数据没了呢?这可能是最恐怖的事情了吧, 我感觉在生产环境中应该没有什么 ...

  6. HDU 5794 A Simple Chess(杨辉三角+容斥原理+Lucas定理)

    题目链接 A Simple Chess 打表发现这其实是一个杨辉三角…… 然后发现很多格子上方案数都是0 对于那写可能可以到达的点(先不考虑障碍点),我们先叫做有效的点 对于那些障碍,如果不在有效点上 ...

  7. Careercup | Chapter 3

    3.1 Describe how you could use a single array to implement three stacks. Flexible Divisions的方案,当某个栈满 ...

  8. 华硕win7安装ubuntu14.04.02注意事项

    一.win7下划出给ubuntu系统的分区 1.win7自带分磁盘的工具,只需要压缩步骤即可,不需要继续分盘符格式化等操作 win7下为绿色 安装时为free space 二.制作启动盘并安装注意事项 ...

  9. react/redux组件库、模板、学习教程

    开源的有蚂蚁金服的: 1.https://pro.ant.design/index-cn 2.https://pro.ant.design/docs/getting-started-cn 3.http ...

  10. Activiti 流程部署方式 activi 动态部署(高级源代码篇)

    Activiti的流程 部署方式有非常多种方式,我们能够依据activit工作流引擎提供的ap方式进行部署. 当然了实际需求决定你要使用哪一种api操作,后面的总结具体介绍了使用场景. 以下看一下部署 ...