ACM-ICPC 2015 BeiJing
本次比赛只写了 A G 然后 I题随后补
A
有一个正方形土地,上面有若干块绿洲。让你以x0为界限划一条竖线,要求左边绿洲面积>=右边绿洲面积且两者面积最接近。另外要求左边的土地总面积最大。求x0
二分 or 扫描线
// 二分 #include<bits/stdc++.h> using namespace std; #define maxn 100010 #define LL long long struct ac{ LL x,y,l,h; }a[maxn]; LL n; bool cmp(ac q,ac w){ return q.x<w.x; } LL work(LL mid){ LL ans=; ;j<n;j++){ if(a[j].l+a[j].x<=mid){ ans+=a[j].l*a[j].h; } else if(a[j].x<=mid&&(a[j].x+a[j].l)>=mid){ ans+=(mid-a[j].x)*a[j].h; }else return ans; } return ans; } int main(){ LL t; cin>>t; while(t--){ LL r,sum=; cin>>r>>n; ;j<n;j++){ cin>>a[j].x>>a[j].y>>a[j].l>>a[j].h; if(a[j].x+a[j].l>=r){ a[j].l=r-a[j].x; } sum+=a[j].l*a[j].h; } //cout<<sum<<endl; sort(a,a+n,cmp); LL ll=,rr=r+,ans; while(ll<rr){ LL mid=(ll+rr)/; ans=; LL ans=work(mid); <sum){ ll=mid+; }else rr=mid; } //cout<<ll<<" "<<rr<<endl; ans=work(ll); while(work(ll)<=ans&&ll<=r){ ll++; } cout<<ll-<<endl; } } // 扫描线 #include<bits/stdc++.h> using namespace std; #define maxn 1000010 #define LL long long LL a[maxn]; int main(){ LL t; cin>>t; while(t--){ LL n,r,sum=; cin>>r>>n; memset(a,,sizeof(a)); ;j<n;j++){ LL x,y,z,zz; cin>>x>>y>>z>>zz; ;k<=x+z;k++){ a[k]+=zz; } sum+=(min(r,x+z)-x)*zz; } LL ans=,j; ;j<r&&ans*<sum;j++){ ans+=a[j]; //cout<<ans<<" "<<j<<endl; } &&j<=r){ j++; } cout<<j-<<endl; } }
G
给你四个矩形 选出来三个看是否可以组成新的矩阵
数据很小直接全排列暴力枚举
#include<bits/stdc++.h> using namespace std; struct ac{ int x,y; }a[]; ]; bool work(){ ; ]].x; ]].y; ]].x; ]].y; ]].x; ]].y; if(w==ww){ h+=hh; i=; }else if(w==hh){ h+=ww; i=; }else if(h==ww){ w+=hh; i=; }else if(h==hh){ w+=ww; i=; } ) ; i=; if(www==w){ i=; }else if(w==hhh){ i=; }else if(h==www){ i=; }else if(h==hhh){ i=; } if(i) ; ; } int main(){ int t; cin>>t; while(t--){ ;j<;j++){ cin>>a[j].x>>a[j].y; b[j]=j; } ; do{ if(work()){ fa=; break; } })); if(fa){ cout<<"Yes"<<endl; }else cout<<"No"<<endl; } }
ACM-ICPC 2015 BeiJing的更多相关文章
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 G. Garden Gathering
Problem G. Garden Gathering Input file: standard input Output file: standard output Time limit: 3 se ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 D. Delay Time
Problem D. Delay Time Input file: standard input Output file: standard output Time limit: 1 second M ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 I. Illegal or Not?
I. Illegal or Not? time limit per test 1 second memory limit per test 512 megabytes input standard i ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 K. King’s Rout
K. King's Rout time limit per test 4 seconds memory limit per test 512 megabytes input standard inpu ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 H. Hashing
H. Hashing time limit per test 1 second memory limit per test 512 megabytes input standard input out ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 C. Colder-Hotter
C. Colder-Hotter time limit per test 1 second memory limit per test 512 megabytes input standard inp ...
- ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 A. Anagrams
A. Anagrams time limit per test 1 second memory limit per test 512 megabytes input standard input ou ...
- hdu 5444 Elven Postman(二叉树)——2015 ACM/ICPC Asia Regional Changchun Online
Problem Description Elves are very peculiar creatures. As we all know, they can live for a very long ...
- 2015 ACM / ICPC 亚洲区域赛总结(长春站&北京站)
队名:Unlimited Code Works(无尽编码) 队员:Wu.Wang.Zhou 先说一下队伍:Wu是大三学长:Wang高中noip省一:我最渣,去年来大学开始学的a+b,参加今年区域赛之 ...
- (并查集)Travel -- hdu -- 5441(2015 ACM/ICPC Asia Regional Changchun Online )
http://acm.hdu.edu.cn/showproblem.php?pid=5441 Travel Time Limit: 1500/1000 MS (Java/Others) Memo ...
随机推荐
- gulp项目和webpack项目在浏览器中查看的方式
在存在.git的目录下,按住shift+左键,打开命令行或者使用git Bash Gulp: 输入gulp dev 本地起一个服务器,在项目中找到gulp.js,然后找本地服务器,找到host和por ...
- [转帖]windows+xshell+xming访问非桌面版Linux服务器
windows+xshell+xming访问非桌面版Linux服务器 2016年06月05日 00:09:11 jxxiaohou 阅读数:11996 标签: Linux 更多 个人分类: Linux ...
- 在Laravel中使用数据库事务以及捕获事务失败后的异常
Description 在Laravel中要想在数据库事务中运行一组操作,则可以在 DB facade 中使用 transaction 方法.如果在事务的闭包内抛出异常,事务将会被自动还原.如果闭包运 ...
- QueryRunner 错误
QueryRunner qr=new QueryRunner(JDBCUtils.getDataSource()); 写成了 QueryRunner qr = new QueryRunner(); 导 ...
- 谈谈B-树和B+树及其应用
待更!!! B-树和B+树的应用:数据搜索和数据库索引 B+/-Tree原理及mysql的索引分析 从B树.B+树.B*树谈到R 树 B树.B-树.B+树.B*树
- js对字符串的一些操作方法
1.charCodeAt(index); 返回一个整数,代表下标位置上字符的Unicode的编码. 2.fromCharCode(code1,code2,code3,...); code1代表Unic ...
- com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class cn.edu.
详细信息 https://www.cnblogs.com/xuwenjin/p/8832522.html 解决办法: 在实体类上面加上注解 @JsonIgnoreProperties(value ...
- C程序运行时的内存分布
该篇博客是自己学习的总结,如果有哪里理解的不对的地方,希望大家可以指点. 一.C内存空间分布图 二.各内存区域详解 1.代码区(.text): 该区域主要存放二进制可执行文件. 2.数据区(.data ...
- CentOS7学习
1.为什么学linux? linux开源免费,系统稳定,多用户的操作系统. linux有许多版本,各个版本之间的不同点大概分三种? > 内核不同 > 集成不同的应用 > 定制不同的图 ...
- 对C#调用C++的dll的一点思考
最近在对接C++程序的时候碰到了一些问题,然后花了一段时间才解决,今天就这些小问题来做一个总结,很多时候由于对另外一种开发语言的不熟悉,会在使用的过程中遇到很多的问题,这些问题看似简单但是背后却有很多 ...