Problem A Arrays

思路:水一水。

 #include<bits/stdc++.h>
using namespace std;
const int N=1e5+;
int n1,n2,k,m,a[N],b[N];
int main()
{
scanf("%d%d",&n1,&n2);
scanf("%d%d",&k,&m);
for(int i=;i<=n1;i++) scanf("%d",&a[i]);
for(int i=;i<=n2;i++) scanf("%d",&b[i]);
if(a[k]<b[n2-m+]) puts("YES");
else puts("NO");
return ;
}

Problem B Order Book

思路:刚开始想优先队列搞一搞一直WA,换了个暴力做法就过了。。。

 #include<bits/stdc++.h>
using namespace std;
const int N=1e5+;
int B[N],S[N];
int n,s,tot1,tot2;
int main()
{
scanf("%d%d",&n,&s);
for(int i=;i<=n;i++)
{
char ss[];
int p,sum;
scanf("%s%d%d",ss,&p,&sum);
if(ss[]=='B') B[p]+=sum;
else S[p]+=sum;
}
int cnt=;
vector<int> ans;
for(int i=;i<=1e5 && cnt<s;i++)
{
if(!S[i]) continue;
ans.push_back(i);
cnt++;
}
sort(ans.rbegin(),ans.rend());
for(int i:ans) printf("S %d %d\n",i,S[i]);
cnt=;
for(int i=1e5;i>= && cnt<s;i--)
{
if(!B[i]) continue;
printf("B %d %d\n",i,B[i]);
cnt++;
}
return ;
}

Problem C  Lengthening Sticks

题目大意:给你a,b,c,l 三个数  将a,b,c分别加上x,y,z,且 x+y+z<=l 问你,有多少种方案使a,b,c能构成三角形。

思路: 模拟的时候没做出来,思路有,写起来巨麻烦,赛后一小时才A掉。。。

我们先将 a 当做最长的边,枚举a的长度,然后往b,c里加的合法长度在 down 到  up之间,问题就变成了,将一个整数

划分成两个整数,划分之后的整数的范围有限制。 然后我找了一下规律,o(1) 算了贡献。 然后我们找两个长边一样的情

况有多少种,三边一样的情况有多少种,总的加起来就是答案。

ps:看了网上的做法,是算不合法的数量,简单多了。。。。

 #include<bits/stdc++.h>
#define ll long long
using namespace std;
int a,b,c,l;
ll ans;
void work(int a,int b,int c)
{
int base=b+c;
for(int i=a;i<=a+l;i++)
{
int u=l-i+a;
if(base+u<=i || i<=b || i<=c) continue;
ll down=max(,i+-base);
ll up=min(u,*(i-)-base);
if(down>up) continue;
ans+=(down++up+)*(up-down+)/;
long long now=i-b-;
if(up>now)
{
long long x=max(down,now+)-now;
long long y=up-now;
ans-=(x+y)*(y-x+)/;
}
now=i-c-;
if(up>now)
{
long long x=max(down,now+)-now;
long long y=up-now;
ans-=(x+y)*(y-x+)/;
}
}
int sum=a+b;
int mx=max(a,b);
for(int i=mx;*i<=l+sum;i++)
{
int res=l-(*i-sum);
int up=min(i-,c+res);
int down=max(,c);
if(down>up) continue;
ans+=up-down+;
}
}
int main()
{
cin>>a>>b>>c>>l;
int mn=min(a,min(b,c));
int mx=max(a,max(b,c));
work(a,b,c); work(b,c,a); work(c,a,b);
int sum=a+b+c;
for(int i=mx;i*<=l+sum;i++) ans++;
printf("%lld\n",ans);
return ;
}

Codeforces Round #317 (div 2)的更多相关文章

  1. Codeforces Round #317 (Div. 2) D Minimization (贪心+dp)

    D. Minimization time limit per test  2 seconds memory limit per test  256 megabytes input  standard ...

  2. Codeforces Round #317 (Div. 2) C Lengthening Sticks (组合,数学)

    一个合法的三角形的充要条件是a<b+c,其中a为最长的一边,可以考虑找出所有不满足的情况然后用总方案减去不合法的情况. 对于一个给定的总长度tl(一定要分完,因为是枚举tl,不分配的长度已经考虑 ...

  3. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  6. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  7. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  8. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  9. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

随机推荐

  1. MySQL - 日常操作一 增删改查

    mysql 源码安装 创建 mysql  账户 组 groupadd mysql useradd mysql -g mysql -M -s /bin/false 解压缩源码安装 .tar.gz cd ...

  2. $_SERVER 当前信息

    连接:https://www.cnblogs.com/mafeng/p/5868117.html $_SERVER['HTTP_ACCEPT_LANGUAGE']//浏览器语言 $_SERVER['R ...

  3. 第18月第2天 ios博客

    1. github https://githuber.cn/search?language=Objective-C https://www.jianshu.com/u/815d10a4bdce htt ...

  4. asp.net mvc 中[Authorize]在IE9以上版本关于FormsAuthentication.SetAuthCookie无效的问题 解决方案

    简单的解决方法是,在网站根目录,新增一个浏览器定义文件(browser definition file) 叫“App_Browsers”文件夹,然后里面放一个“IE10.browser”文件即可,网站 ...

  5. sybench压测下模拟误truncate数据恢复

    基本环境:官方社区版MySQL 5.7.21 Row+Gtid开启sysbench压测,使用mysqldump备份数据库,执行truncate操作,恢复数据到truncate前的时间点1.切换日志,记 ...

  6. SpringBoot集成SpringCloud

    (1).新建一个普通Maven项目,用于存放一些公共服务接口及公共的Bean等. 项目结构: 公共Bean: package cn.coreqi.entities; import java.io.Se ...

  7. springboot学习笔记-6 springboot整合RabbitMQ

    一 RabbitMQ的介绍 RabbitMQ是消息中间件的一种,消息中间件即分布式系统中完成消息的发送和接收的基础软件.这些软件有很多,包括ActiveMQ(apache公司的),RocketMQ(阿 ...

  8. 【转】inotify+rsync实现实时同步

    [转]inotify+rsync实现实时同步 1.1 什么是实时同步:如何实现实时同步 要利用监控服务(inotify),监控同步数据服务器目录中信息的变化 发现目录中数据产生变化,就利用rsync服 ...

  9. Python3学习笔记18-访问限制

    在Class内部,可以有属性和方法,而外部代码可以通过直接调用实例变量的方法来操作数据,这样,就隐藏了内部的复杂逻辑. 但是,从Student类的定义来看,外部代码还是可以自由地修改一个实例的name ...

  10. C# 文件拖放

    将控件的属性AllowDrop设置为true,然后添加DragDrop.DragEnter时间处理函数 private void FormMain_DragEnter(object sender, D ...