CodeForces 572A

题意:给定两个序列,问能否从第一个序列取出k个数,从第二个序列取出m个数,使得第一个序列取出来的所有数都小于第二个序列取出来的数。

思路:水。因为问的是存在,所以只要在第一个序列中取最小的k个和第二个序列中最大的m个,然后比较第一取出来最大是否小于第二取出来最小。

code:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF=0x3fffffff;
const int inf=-INF;
const int N=1e5+5;
const int M=2005;
const int mod=1000000007;
const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define cpy(x,a) memcpy(x,a,sizeof(a))
#define ft(i,s,n) for (int i=s;i<=n;i++)
#define frt(i,s,n) for (int i=s;i>=n;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt  rt<<1
#define rrt  rt<<1|1
#define middle int m=(r+l)>>1
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define mk make_pair
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);int v1[N],v2[N];
int main()
{int n1,n2,k,m;scanf("%d%d",&n1,&n2);scanf("%d%d",&k,&m);ft(i,1,n1) scanf("%d",&v1[i]);ft(i,1,n2) scanf("%d",&v2[i]);if (v1[k]<v2[n2-m+1]) puts("YES");else puts("NO");
}

CodeForces 572B

题意:给定一些股票的买卖情况,然后买高卖低,然后按价格从大到小输出买卖的股票的序列。

思路:直接开两个数组,一个存取买的,一个存取卖的。输出的时候从100000向下(从0到上)遍历即可。

code:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF=0x3fffffff;
const int inf=-INF;
const int N=100005;
const int M=2005;
const int mod=1000000007;
const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define cpy(x,a) memcpy(x,a,sizeof(a))
#define ft(i,s,n) for (int i=s;i<=n;i++)
#define frt(i,s,n) for (int i=s;i>=n;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt  rt<<1
#define rrt  rt<<1|1
#define middle int m=(r+l)>>1
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define mk make_pair
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);int mp1[N],mp2[N];
int main()
{int n,m;int d,p;char s[2];scanf("%d %d",&n,&m);cls(mp1,0);cls(mp2,0);ft(i,1,n){scanf("%s %d %d",&s,&p,&d);if (s[0]=='S') mp1[p]+=d;else mp2[p]+=d;}int k=0,t=0;for(int it=0;it<N&&t<m;it++){//if (it%100==0)printf("%d\n",it);//if (it>100000) break;if (mp1[it]>0)  t++,k=it;}for (int j=k;j>=0;j--) if (mp1[j]>0) printf("S %d %d\n",j,mp1[j]);t=0;for(int it=N;it>=0&&t<m;it--){if (mp2[it]>0) printf("B %d %d\n",it,mp2[it]),t++;}
}

CodeForces 572C

题意:给定一个三角形的三边a,b,c和要延长的长度l,问有多少种方法可以使得延长后的图形为三角形。

思路:先找所有的情况,然后减去不满足的情况。当l为i时,情况为c(i+2,2)(i可以去0-l,一路累加即可)。减去分别以a,b,c作为最长边枚举就算把剩下边加上也无法满足三角形的情况。

code:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>using namespace std;typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;const int INF=0x3fffffff;
const int inf=-INF;
const int N=1000000;
const int M=2005;
const int mod=1000000007;
const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))
#define cpy(x,a) memcpy(x,a,sizeof(a))
#define ft(i,s,n) for (int i=s;i<=n;i++)
#define frt(i,s,n) for (int i=s;i>=n;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt  rt<<1
#define rrt  rt<<1|1
#define middle int m=(r+l)>>1
#define lowbit(x) (x&-x)
#define pii pair<int,int>
#define mk make_pair
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);ll sol(ll a,ll b,ll c,ll l){ll t=0;for(ll i=max(b+c-a,0ll);i<=l;i++){ll x=min(l-i,a+i-b-c);t+=(x+1)*(x+2)/2;}return t;
}
int main()
{ll a,b,c,l,ans=0;cin>>a>>b>>c>>l;for(ll i=0;i<=l;i++) ans+=(i+1)*(i+2)/2;ans-=sol(a,b,c,l);ans-=sol(b,c,a,l);ans-=sol(c,a,b,l);cout<<ans<<endl;
}

CodeForces 572A,B,C相关推荐

  1. CodeForces 560A,B,C

    CodeForces 560A 题意:给定一个货币系统,问不能组成的最小的钱数是多少. 思路:水,只要检查有没有出现1即可,有则输出-1,否则1. code: #include <iostrea ...

  2. 【CodeForces - 574B】Bear and Three Musketeers (枚举边,思维,优秀暴力)

    题干: Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Ri ...

  3. Codeforces Round #408 (Div. 2)-C. Bank Hacking-(三种方法)分类讨论,二分,集合

    补题速度太慢了,这样可不行啊. 代码里都有解释. 看别人代码有三种写法 set,分类,和二分. 这是个是用分类思想写的, #include <bits/stdc++.h> using na ...

  4. Codeforces Round #552 (Div. 3) A B C D E F G (暴力,dp,模拟)

    题目链接:https://codeforces.com/contest/1154 A:Restoring Three Numbers B:Make Them Equal C:Gourmet Cat D ...

  5. Codeforces Round #630 (Div. 2) A~D【思维,数论,字符串,位运算】

    A. Exercising Walk 水题一道:在指定空间内你一定要向各个方向走a,b,c,d步问你能否在规定空间内走完这题的坑点样例都给出来了qwq #include <iostream> ...

  6. 【CodeForces - 1047C】Enlarge GCD(数学,枚举,预处理打表,思维)

    题干: F先生有n个正整数,a1,a2,...,an 他认为这些整数的最大公约数太小了,所以他想通过删除一些整数来扩大它 您的任务是计算需要删除的最小整数数,以便剩余整数的最大公约数大于所有整数的公约 ...

  7. 【CodeForces - 545 ABCDE套题训练题解】贪心, 构造,模拟,dp,最短路树(Dijkstra+变形)

    A: 题干: Input The first line contains integer n (1 ≤ n ≤ 100) - the number of cars. Each of the next  ...

  8. 【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)

    题干: Given the number n, find the smallest positive integer which has exactly n divisors. It is guara ...

  9. 【CodeForces - 260D】Black and White Tree (思维构造,猜结论,细节,构造一棵树)

    题干: The board has got a painted tree graph, consisting of n nodes. Let us remind you that a non-dire ...

最新文章

  1. Linux驱动无硬件设备,Linux设备驱动与硬件通信
  2. 使用说明 vector_C++核心准则编译边学-F.20 输出结果时应该使用返回值
  3. python画三维立体图-Python+matplotlib绘制三维图形5个精选案例
  4. LeetCode 88. 合并两个有序数组(Merge Sorted Array)
  5. NSDate与NSDateFormatter的相关用法
  6. leetcode337. 打家劫舍 III
  7. Idea中搭建Resin运行环境(Mac)
  8. Java多线程学习四十三:
  9. 决策树 prepruning_决策树与随机森林
  10. 中文代码示例之Vuejs入门教程(一)
  11. MySQL中向下查询_mysql
  12. 搭建ftp_Windows 10搭建FTP服务器!
  13. 【电子科技大学-微电子技术导论】学习笔记
  14. 用python写微信红包脚本_python 实现模拟微信发红包
  15. 根据UA获取用户访问操作系统、浏览器名
  16. RPC框架原理与实现
  17. 《ppt》word插入批注,修改作者
  18. linux setlocale函数,linux中的多语言环境(LC_ALL, LANG, locale)
  19. BGA焊接可靠性评价指引,为产品质量保驾护航
  20. Markdown编辑器使用方法

热门文章

  1. AJAX跨域问题解决方法(1)——禁止浏览器进行跨域限制
  2. 《H5 移动营销设计指南》 读书笔记整理
  3. 基于webpack3.x从0开始搭建React开发环境
  4. 从计算机体系结构方面思考深度学习
  5. width:100vh与min-height:calc(100vh + 51px)
  6. xamarin UWP中MessageDialog与ContentDialog的区别
  7. C语言操作mysql
  8. hdu1053 Entropy hdu2527 Safe Or Unsafe
  9. 输入参数的数目不足_sklearn.decomposition.PCA 参数速查手册
  10. git显示服务器所有分支,git 查看所有远程分支以及同步