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 ...
随机推荐
- oracle查询不走索引的一些情况(索引失效)
Oracle建立索引的目的是为了避免全表扫描,提高查询的效率. 但是有些情况下发现即使建立了索引,但是写出来的查询还是很慢,然后会发现是索引失效导致的,所以需要了解一下那些情况会导致索引失效,即查询不 ...
- 深入解读Promise对象
promise对象初印象: promise对象是异步编程的一种解决方案,传统的方法有回调函数和事件,promise对象是一个容器,保存着未来才会结束的事件的结果 promise对象有两个特点: 1.p ...
- centos7之vm11添加网卡
需求 根据实际需求原来有一块网卡,现在需要新加一块网卡做集群. 1.在虚拟机添加一块网卡,开机后ip a查看是不是新加了一块网卡,下图是为了讲解,其实已经是做完的状态. 2.上满我们看到新加了一块网卡 ...
- linux中的set -e 与set -o pipefail
1.set -e "Exit immediately if a simple command exits with a non-zero status." 在“set -e”之后出 ...
- linux中一些特殊的中文文件不能删除问题
例: [root@iZ2zecl4i8oy1rvs00dqzeZ tmp]# ,),(,,' [root@iZ2zecl4i8oy1rvs00dqzeZ tmp]# echo "rm -rf ...
- java & jdk
java & jdk JDK 下载太慢 & java 12 https://download.oracle.com/otn-pub/java/jdk/12.0.1+12/69cfe15 ...
- OSError: mysql_config not found
使用Python3开发一个管理平台,用MySQL数据库存放元数据.使用pip安装mysqlclient模块时出现“OSError: mysql_config not found”错误. 解决: # a ...
- Python——Flask框架——数据库
一.数据库框架 Flask-SQLAlchemy (1)安装: pip install flask-sqlalchemy (2)Flask-SQLAlchemy数据库URL 数据库引擎 URL MyS ...
- JavaScript简单简介
JavaScript,男,web页面的一种脚本编程语言,1955年诞生,妻子为HTML,魔法能力是将静态页面(经过与用户交互与相应)转变为动态页面. 刚进入浏览器市场(魔界)的时候,也就是js1.0岁 ...
- python学习日记(python2/3区别补充,is / id/ encode str,bytes)
python2和python3区别 print python2中,print 是语句 :用法 ---->print '***' python3中,print 是函数:用法----->pri ...