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 ...
随机推荐
- HTML中的几种空格
HTML提供了5种空格实体(space entity),它们拥有不同的宽度,非断行空格( )是常规空格的宽度,可运行于所有主流浏览器.其他几种空格( )在不同浏览器中宽度各异. ...
- MySQL dump文件导入
1 打开cmd 输入要导入的数据库,用户名,密码,dump文件路径 mysql -u employees <E:\employees_db\load_departments.dump
- [转帖]Docker 清理占用的磁盘空间
Docker(二十七)-Docker 清理占用的磁盘空间 https://www.cnblogs.com/zhuochong/p/10076599.html docker system docker ...
- [官网]CREATE EXTENSION PostGreSQL 创建函数的方法
CREATE EXTENSION https://www.postgresql.org/docs/current/sql-createextension.html CREATE EXTENSION — ...
- AngularJS双向数据绑定
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Spirng boot maven多模块打包不踩坑
本文参考 https://blog.csdn.net/Ser_Bad/article/details/78433340 经过实战一次通过.回话不多说,话费不多说,直接上图. 项目整体结构: 父模块: ...
- python 列表、元组、字典
一.列表 [ ] 如下的列子都可以成为列表,c=[1,2,3,4,5,6],d=["abc", "张三",“李四”],e=[1,2,3,"abc&qu ...
- sublime text3安装代码格式化的步骤
1.首先查看有没有安装package control插件,若没有,进行此链接操作——http://blog.csdn.net/kongguyoulan523/article/details/51144 ...
- 使用urllib2+re爬取web网站
应用1,使用urllib2+re爬取淘宝网指定页面的所有图片
- python 编码格式
1. 字符编码简介 1.1. ASCII ASCII(American Standard Code for Information Interchange),是一种单字节的编码.计算机世界里一开始只有 ...