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. web.py 模板错误记录

    错误信息 Traceback (most recent call last): File , in process return self.handle() File , in handle retu ...

  2. CSS魔法(四)常用属性

    元素的显示与隐藏 display.visibility.overflow 在CSS中有三个显示和隐藏的单词比较常见,我们要区分开,他们分别是 display.visibility 和 overflow ...

  3. android ListView 分页加载数据

    1.mainActivity <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" ...

  4. Java EE 之 Hibernate异常总结【4】org.hibernate.exception.SQLGrammarException: could not execute statement

    本质原因:配置的Java Bean,由Hibernate自动产生的SQL语句中有语法错误 原因如下: 情况1.存在字段名/表名与数据库关键字冲突 情况2.MySQL5.0以后与MySQL5.0以前事务 ...

  5. float/double 浮点数据*100精度丢失问题

    工作中微信支付碰到的一个问题,金额是float数字,微信参数需要分且必须是整数,所以*100的时候就有问题了 System.out.println(9.9f*100); //989.99994Syst ...

  6. IAR KEIL ECLIPSE使用JlinkScript文件进行调试

    转载自:https://wiki.segger.com/Using_J-Link_Script_Files Using J-Link Script Files     Contents [hide]  ...

  7. UML和模式应用5:细化阶段(5)---系统顺序图

    1.前言 系统顺序图(SSD)是为阐述系统相关的输入和输出事件而快速.简单的创建的制品,它们是操作契约和对象设计的输入. SSD展示了直接与系统交互的外部参与者.系统(作为黑盒)以及由参与者发起的系统 ...

  8. cocos2d-x播放视频的处理

    cocos2d-x是支持直接播放视频的,用的是Native端的播放器,视频的默认层级是在cocos的层级之上,如果是想让视频上面有cocos的控件,只能将视频的UI层级放在最下面,这个方法网上已经有比 ...

  9. PYTHON-模块-time&datetime-练习 +目录规范

    # 作业# 1.请写出规范目录# 并解释各文件夹的作用bin 可执行文件conf 配置文件core 主要业务逻辑db 数据文件lib 库(公共代码 第三方模块)log 日志文件 # 2.改造atm + ...

  10. android录音实现不再担心—一个案例帮你解决你的问题

    最近有小伙伴经常android的录音怎么实现,有没有相关的案例.今天给大家推荐一个android中实现录音和播放的小案例. 效果图: 一.实现录音的 Service 关键代码: // 开始录音 pub ...