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),然后让总和最大. 首先可以计算出初始的总和,以及每 ...
随机推荐
- LFYZOJ 104 Counting Swaps
题解 #include <iostream> #include <cstdio> #include <algorithm> #include <cmath&g ...
- windows7下如何生成ssh公钥(git相关)
1. 安装git,从程序目录打开 "Git Bash" 2. 键入命令:ssh-keygen -t rsa -C "email@email.com" &q ...
- poj 1970(搜索)
The Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6247 Accepted: 1601 Descript ...
- 十六进制字符串jpg图片互转
十六制字符串jpg图片互转(格式:FFD8FFE000104A******)如:FFD8FFE000104A46494600010100000100010000FFDB0043000806060706 ...
- (1)sqlite基础
一.安装sqlite 下载页面:http://www.sqlite.org/download.html 1.下载 sqlite-tools-win32-*.zip 和 sqlite-dll-win32 ...
- HDU 1045 Fire Net 状压暴力
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others) ...
- luogu P1018 乘积最大
题目描述 今年是国际数学联盟确定的"2000――世界数学年",又恰逢我国著名数学家华罗庚先生诞辰90周年.在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活动,你的一 ...
- 【UTR #2】题目交流通道
题目描述 定好了难度,雄心勃勃的吉米多出题斯基开始寻找智慧的神犇星球的居民出题. 然而吉米多出题斯基没有料到,神犇星球的居民告诉吉米多出题斯基:"今年神犇星球经济不景气,大家都想宅在家里,哪 ...
- jquery 全选获取值
首选区分一下prop与attr的差别.prop是固有属性,attr自定义属性. $("#all").click(function () {//全选.反选 if(this.check ...
- Opencv 图片边缘检测和最小外接矩形
#include "core/core.hpp" #include "highgui/highgui.hpp" #include "imgproc/i ...