BestCoder #47 1001&&1002
【比赛链接】 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;
}
1
2 2
2 3
2 2
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;
}
2
3 5
1 -1 2
3 -2
1 -1 2
8
2
BestCoder #47 1001&&1002的更多相关文章
- 简单几何(水)BestCoder Round #50 (div.2) 1002 Run
题目传送门 /* 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 */ /***** ...
- BestCoder #88(1001 1002)
Find Q Accepts: 392 Submissions: 780 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131 ...
- 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 ...
- HOJ 1001: A+B; 1002: A+B+C
两道水题,用来熟悉 HOJ 的提交系统. 1001:输入两个整数 A, B (0 <= A,B <= 10),输出 A+B. #include <iostream> using ...
- Bestcoder #47 B Senior's Gun
Senior's Gun Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- BestCoder Round #68 (div.2) 1002 tree
题意:给你一个图,每条边权值0或1,问每个点周围最近的点有多少个? 思路:并查集找权值为0的点构成的连通块. #include<stdio.h> #include<string.h& ...
- BestCoder Round #50 (div.1) 1002 Run (HDU OJ 5365) 暴力枚举+正多边形判定
题目:Click here 题意:给你n个点,有多少个正多边形(3,4,5,6). 分析:整点是不能构成正五边形和正三边形和正六边形的,所以只需暴力枚举四个点判断是否是正四边形即可. #include ...
- bestcoder#23 1001 Sequence
Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- ACM学习历程—HDU5586 Sum(动态规划)(BestCoder Round #64 (div.2) 1002)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5586 题目大意就是把一段序列里面的数替换成f(x),然后让总和最大. 首先可以计算出初始的总和,以及每 ...
随机推荐
- <编程精粹:编写高质量C语言代码> 读书笔记
0.规则<The Elements of Programming Style><The Elements of Style> 1.假想的编译程序(1)使用编译器提供的所有的可选 ...
- Java-动态规划-最多苹果数量的方法
平面上有N*M个格子,每个格子中放着一定数量的苹果.你从左上角的格子开始,每一步只能向下走或是向右走,每次走到一个格子上就把格子里的苹果收集起来,这样下去,你最多能收集到多少个苹果. 思路: 解这个问 ...
- linux内核中打印栈回溯信息 - dump_stack()函数分析【转】
转自:http://blog.csdn.net/jasonchen_gbd/article/details/45585133 版权声明:本文为博主原创文章,转载请附上原博链接. 目录(?)[-] ...
- 第6章 I/O多路复用
前一章节客户端同时处理两个输入:标准输入和TCP套接字,然而问题在于客户端阻塞于fgets调用期,服务器进程被杀死后,服务器tcp虽然可以正确发送一个fin,但进程正阻塞于标准输入,它无法看到eof, ...
- C语言处理json字符串
JSON语法说明 先来看一个简单的JSON 1 { 2 "stars": [ 3 { 4 "name": "Faye", 5 "a ...
- llinux 定时器 转载自 http://blog.chinaunix.net/uid-11848011-id-96374.html
这篇文章主要记录我在试图解决如何尽可能精确地在某个特定的时间间隔执行某项具体任务时的思路历程,并在后期对相关的API进行的归纳和总结,以备参考. 问题引出 很多时候,我们会有类似“每隔多长时间执行某项 ...
- 查看公网IP信息的方法
有时候我们想知道自己的外网ip,推荐几个好用的方法 windows 用百度搜索“ip”就会显示 用浏览器访问getip.name 或者 ifconfig.me linux 使用curl命令 curl ...
- poj 1950(搜索)
Dessert Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5430 Accepted: 2029 Descripti ...
- AC日记——教辅的组成 洛谷 P1231
题目背景 滚粗了的HansBug在收拾旧语文书,然而他发现了什么奇妙的东西. 题目描述 蒟蒻HansBug在一本语文书里面发现了一本答案,然而他却明明记得这书应该还包含一份练习题.然而出现在他眼前的书 ...
- HDU 5266 pog loves szh III(区间LCA)
题目链接 pog loves szh III 题意就是 求一个区间所有点的$LCA$. 我们把$1$到$n$的$DFS$序全部求出来……然后设$i$的$DFS$序为$c[i]$,$pc[i]$为$c ...