CodeForces Round 200 Div2
2013-09-15 12:50
225 查看
这次比赛出的题真是前所未有的水!只用了一小时零十分钟就过了前4道题,不过E题还是没有在比赛时做出来,今天上午我又把E题做了一遍,发现其实也很水.昨天晚上人品爆发,居然排到Rank 55,运气好的话没准能领到T-shirt.除此之外,锁上程序之后,看到一个人数组开小了,我还提交了一个大数据,成功Hack了一次,然后Room排名顿时升到第1.
My submissions
View Code
My submissions
#include<stdio.h> #define i64 __int64 int N,M; __int64 H[100005],R[100005]; i64 abs(i64 x) { if (x<0) return -1*x; else return x; } i64 max(i64 x,i64 y) { return x>y ? x:y; } bool judge(i64 T) { int cur=1; i64 final; for (int i=1;i<=N;i++) { if (abs(H[i]-R[cur])>T) continue; if (R[cur]==H[i]) cur++; if (R[cur]<H[i]) final=max(H[i]+T-2*(H[i]-R[cur]),H[i]+(T-(H[i]-R[cur]))/2); else final=H[i]+T; while (R[cur]<=final && cur<=M) cur++; } return (cur>M); } int main() { freopen("input.txt","r",stdin); while (scanf("%d%d",&N,&M)!=EOF) { int i; for ( i=1;i<=N;i++) scanf("%I64d",&H[i]); for ( i=1;i<=M;i++) scanf("%I64d",&R[i]); i64 l=-1,r=abs(H[1]-R[1])*2+abs(H[1]-R[M]),mid; while (l+1<r) { mid=(l+r)>>1; if (judge(mid)) r=mid; else l=mid; } printf("%I64d\n",r); } return 0; }
View Code
相关文章推荐
- Codeforces Round #200 (Div. 2)344D Alternating Current(栈)
- Codeforces Round #200 (Div. 1) D. Water Tree
- Codeforces Round #200 (Div. 2)E
- Codeforces Round #200 (Div. 2) (ABCDE题解)
- Codeforces Round #200 (Div. 1) Water Tree (dfs序+线段树)
- Codeforces Round 200 Div1 D Water Tree (树上线段树)
- Codeforces Round #200 (Div. 1)
- Codeforces Round #200 (Div. 1) D. Water Tree(dfs序+线段树)
- Codeforces Round #200 (Div. 1)D Water Tree
- 【Codeforces Round #200 Div.1 E】【JZOJ 5406】 Tree
- codeforces round 200 div2解题报告
- Codeforces Round #200 Div.1 E tree
- Codeforces Round #200 (Div. 1) D - Water Tree 很经典而且很有趣的树 上dfs问题
- Codeforces Round #200 (Div. 2)
- Codeforces Round #200 (Div. 2)
- Codeforces Round #200 (Div. 1)D. Water Tree 【dfs序+线段树】
- Codeforces Round #200 (Div. 1) D.Water Tree
- Codeforces Round #200 (Div. 1)A. Rational Resistance 数学
- Codeforces Round #200 (Div. 2)A. Magnets
- Codeforces Round #200 (Div. 1) (树上的线段树)