【比赛链接】

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. docker基础——自定义镜像、创建私有仓库、查看 docker 运行状态

    一.自定义镜像 1,案例1 要求:请自定义一个 docker 镜像,基于 hub.c.163.com/library/centos,要求创建出来的镜像在生成容器的时候,可以直接使用 ifconfig ...

  2. TroubleShoot: SPD 2013 工作流模板问题解决办法

    1. 问题描述: SPD 2013 不能使用2013 工作流模板,在创建过程中,下载更新信息时出现以下错误描述: The server has tried to deliver this messag ...

  3. 37深入理解C指针之---结构体与指针

    一.结构体与指针 1.结构体的高级初始化.结构体的销毁.结构体池的应用 2.特征: 1).为了避免含有指针成员的结构体指针的初始化复杂操作,将所有初始化动作使用函数封装: 2).封装函数主要实现内存的 ...

  4. JD静态网页

    1.制作导航栏 ul>li*n>a 2.制作竖线 a.利用border b.利用  | c.利用矩形,宽度设为1,设置背景色,padding = 0 3.制作下三角 (1)◇ (2)两个盒 ...

  5. screen状态变Attached连接会话失败

    使用xshell远程登录主机,使用screen命令启动程序运行至后台,意外发现screen session的状态为Attached,使用命令screen -r <session-id>,提 ...

  6. nginx和php通信

    #启动php-fpm服务 #配置nginx.conf worker_processes ; worker_rlimit_nofile ; worker_cpu_affinity ; #error_lo ...

  7. ios中表示private

    在.m中写成 如下形式既为私有的形式 @interface ViewController ()  这里只是声明类名和括号即可 /////方法等 @end

  8. weblogic92 启动慢解决办法

      使用SUN JDK 启动时要很长时间,但启动启来weblogic正常. 特征见下面标红部分,时间很长. test01@linux-suse:~/bea/weblogic92/samples/dom ...

  9. table 设置边框

    本文引自:https://www.cnblogs.com/leona-d/p/6125896.html 示例代码: <!DOCTYPE html> <html lang=" ...

  10. C++字符串操作二

    #include <iostream> #include <assert.h> using namespace std; //模拟实现strcmp函数. bool my_str ...