Chang'an(Dance Party-贪心)
来源:互联网 发布:学校网络舆情自查报告 编辑:程序博客网 时间:2024/06/06 01:36
贪心,尽量向前配
#include <bits/stdc++.h>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define MAXN (2000)#define eps (1e-6)int T,a[MAXN],b[MAXN];int main(){//freopen("H.in","r",stdin);cin>>T;For(kcase,T){int n;scanf("%d",&n);For(i,n) scanf("%d",&a[i]);sort(a+1,a+1+n);int m;scanf("%d",&m);For(i,m) scanf("%d",&b[i]);sort(b+1,b+m+1);int j=1,ans=0;For(i,n){while (j<=m&&a[i]+1>=b[j]){if (abs(a[i]-b[j])<=1) {ans++;j++;break;}j++;}if (j>m) break;}printf("%d\n",ans);}return 0;}
0 0
- Chang'an(Dance Party-贪心)
- 贪心——Codeforces814D An overnight dance in discotheque
- coderforces 814 D. An overnight dance in discotheque(贪心)
- codeforces 814D An overnight dance in discotheque(贪心)
- Codeforces 814D-An overnight dance in discotheque 贪心
- Codeforces-814D An overnight dance in discotheque(贪心)
- hust 1024 dance party
- hust 1024 dance party
- hust 1024 dance party
- [Codeforces 814D] An overnight dance in discotheque 树形dp,贪心
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque(思维 贪心)
- Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 贪心
- Chang'an(YY's string-模拟)
- Chang'an(Hack-01分数规划)
- Chang'an(Palindrome Numbers-回文数字统计)
- Chang'an(YY's problem-矩阵乘法)
- Chang'an(Black Box-线段树)
- 【hust1024】【二分法】【最大流】dance party
- android屏幕适配详解
- 利用DSHOW中的VMR9 filter 将视频渲染成纹理 供D3D使用
- 【c语言】求两个整数中的较大者
- Spring学习4-面向切面(AOP)之Spring接口方式
- Tomcat配置详解
- Chang'an(Dance Party-贪心)
- java动态代理一(java自带动态代理)
- 输入一个链表,输出该链表中倒数第k个结点。
- vim中lua require路径的gf跳转
- springmvc学习笔记(12)——ModelAttribute
- struct与typedef struct
- 无监督特征学习——Unsupervised feature learning and deep learning
- IOS怎么样更有效率更全面的使用xcode
- 使用Eclipse构建Maven项目