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 ...
随机推荐
- toFixed方法的bug
最近在工作过程中碰到一个隐藏的bug,经调试发现竟然是toFixed函数不可靠的结果引起的.后端同学在处理价格比较的时候,用foFixed进行价格的四舍五入之后,竟然发现比较的结果有问题: 大家都知道 ...
- W3C规范
连接:https://www.w3cschool.cn/xuexiw3c/xuexiw3c-standards.html W3C 代码标准规范 由 路飞 创建, 最后一次修改 2017-01-03 W ...
- luogu P3924 康娜的线段树
题面传送门 我们可以画图找规律 这里没图,要看图可以去看M_sea dalao的题解(逃 可以发现单个节点\(i\)对答案的贡献为该节点的点权\(*\frac{1}{2^{dep_i}}\)(\(de ...
- POJ 1035 Spell checker (模拟)
题目链接 Description You, as a member of a development team for a new spell checking program, are to wri ...
- Poj3696 The Lukiest Number
传送门 Solution 懒得写啦 Code #include<iostream> #include<cstdio> #include<cmath> #define ...
- HTML学习笔记04-样式
HTML<style>属性 style属性的作用: 提供了一种改变所有HTML元素样式的通用方法 background-colco属性为元素定义了背景颜色: <!DOCTYPE HT ...
- Bootstrap3.0学习第五轮(表格)
详情请查看 http://aehyok.com/Blog/Detail/11.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本文文章链接:h ...
- windows使用python原生组件包获取系统日志信息
#coding=utf8 import sys import traceback import win32con import win32evtlog import win32evtlogutil i ...
- Oracle常用sql语句(一)
# Sql的分类 # DDL (Data Definition Language):数据定义语言,用来定义数据库对象:库.表.列等: CREATE. ALTER.DROP DML(Data Manip ...
- Annoy 近邻算法
Annoy 随机选择两个点,以这两个节点为初始中心节点,执行聚类数为2的kmeans过程,最终产生收敛后两个聚类中心点 二叉树底层是叶子节点记录原始数据节点,其他中间节点记录的是分割超平面的信息 但是 ...