Codeforces Round #317 (div 2)
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)的更多相关文章
- Codeforces Round #317 (Div. 2) D Minimization (贪心+dp)
D. Minimization time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #317 (Div. 2) C Lengthening Sticks (组合,数学)
一个合法的三角形的充要条件是a<b+c,其中a为最长的一边,可以考虑找出所有不满足的情况然后用总方案减去不合法的情况. 对于一个给定的总长度tl(一定要分完,因为是枚举tl,不分配的长度已经考虑 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
- 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 ...
随机推荐
- HTML5 元素拖拽实现 及 jquery.event.drag插件
如上图片: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" c ...
- javaScript事件系统详解
一个有情怀的猴子
- odp.net连接方式,部署问题总结
一. 摘要 在C#开发的过程中,经常需要操作Oracle数据库,而实际在部署程序的时候,经常要根据系统环境(32.64bit).不安装Oracle客户端等等需求,而Odp.net 也没有完美兼容的 ...
- Linux - 账户切换授权
sudo 切换账户 echo myPassword | sudo -S ls /tmp # 直接输入sudo的密码非交互,从标准输入读取密码而不是终端设备 visudo # sudo命令权限添加 /e ...
- 串行动画组QSequentialAnimationGroup
按顺序执行动画 该类就是用来按照动画添加顺序来执行动画的.我们只用实例化该类,然后通过调用addAnimation()或者insertAnimation()方法把各个动画添加进去就可以了 import ...
- NOIP2018ty记
前置传送门:noip2018前流水账 Day-inf~Day-3 写流水账里了 懒得再写了 Day-2~Day-1 做了些noip的原题 真是奇怪,我天天爱跑步和逛公园都是1A的,结果反而有些普及组的 ...
- MySQL自动设置create_time和update_time
参考表结构 CREATE TABLE `t_baby` ( `baby_id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, ...
- python基础知识~配置文件模块
一 配置文件模块 import ConfigParser ->导入模块 conf = ConfigParser.ConfigParser() ->初始化类二 系统函数 conf.r ...
- android 使用web查看SQLite数据
添加依赖: compile 'com.facebook.stetho:stetho:1.4.2'compile 'com.facebook.stetho:stetho-okhttp3:1.4.2' 初 ...
- LogParse-Windows系统日志分析
Windows系统日志分析 一.前言 本文将对常见的日志类型,利用微软日志分析工具(LogParser)结合已经掌握的恶意代码分析Windows系统日志,关联出系统的异常. 数据来源于Windows的 ...