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. quartz定时任务-job

    1,首先添加对quartz组建的引用 quartz-2.2.3.jar,slf4j-api-1.7.7.jar https://files.cnblogs.com/files/renjing/quar ...

  2. Java入门系列(十)Java IO

    概述 总体而言,java的读写操作又分为两种:字符流和字节流. 实际上字节流在操作时本身不会用到缓冲区(内存),是文件本身直接操作的,而字符流在操作时使用了缓冲区,通过缓冲区再操作文件. 什么是流? ...

  3. Win Server 2008 R2 IIS 默认只能添加一个 443 HTTPS 端口

    问题: 解决方案: 方法一: 然后在:C:\Windows\system32\inetsrv\config\applicationHost.config 找到 对应网站 <binding pro ...

  4. # 20155337 2016-2017-2 《Java程序设计》第八周学习总结

    20155337 2016-2017-2 <Java程序设计>第八周学习总结 教材学习内容总结 第14章 NIO与NIO2 NIO简介 NIO使用频道来衔接数据结点,在处理数据时,NIO可 ...

  5. JavaScript之表格操作(二)创建表格病填充表格数据

    //创建表格 var tableOptions = { way: "insertBefore", //insertBefore,append positionId: "d ...

  6. luogu P3576 [POI2014]MRO-Ant colony

    传送门 一群蚂蚁能被吃,也就是走到指定边的两端点之一要走到另一端点时有\(k\)只,我们可以从这两端点逆推,记两个值为走到某个点时最后会被吃掉\(k\)只蚂蚁的蚂蚁数量范围,式子下面有,很好理解(雾) ...

  7. 使用sqlmap中tamper脚本绕过waf

    使用sqlmap中tamper脚本绕过waf 刘海哥 · 2015/02/02 11:26 0x00 背景 sqlmap中的tamper脚本来对目标进行更高效的攻击. 由于乌云知识库少了sqlmap- ...

  8. Android NDK编程

    1.首先需要声明native方法: public native String helloWorldNdk(); public native String hello_World_Ndk(); 2.然后 ...

  9. 对numpy中shape的理解

    from:http://blog.csdn.net/by_study/article/details/67633593 环境:Windows, Python3.5 一维情况: >>> ...

  10. 【转】CentOS 7.X 系统安装及优化

    [转]CentOS 7.X 系统安装及优化 centos的演变 启动流程sysvinit 串行启动:一次一个,一个一个启动 并行启动:全部的一起启动 init优点 运行非常良好.主要依赖于shell脚 ...