BJTUOJ 1858 hwf 的签到(水~)

11 篇文章 1 订阅

Description

hwf h w f 每天都会通过做题来签到,今天也不例外。

他上午做了 a a 道题,下午做了b道题,但是 hwf h w f 记忆力不太好,刷一题,忘一题,所以有时候可能会刷重复的题,现在 hwf h w f 想知道自己一天一共刷了多少的题(同一题刷多次只算一次)。

Input

第一行有两个整数 a,b(0a,b100000) a , b ( 0 ≤ a , b ≤ 100000 ) 分别代表上午写的题目数量和下午写的题目数量。

第二行有 a a 个整数,第i个数 ai a i 表示上午刷的题号 (1ai1000000) ( 1 ≤ a i ≤ 1000000 )

第三行 b b 个数,第i个数 bi b i 表示下午刷的题号 (1bi1000000) ( 1 ≤ b i ≤ 1000000 )

Output

一个整数,表示他今天做了多少道题。

Sample Input

2 2
1 2
1 3

Sample Output

3

Solution

水题,开个标记数组标记下已经做过的题然后累加标记即可

Code

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=1000005;
int n,m,a,vis[maxn],ans=0;
int main()
{
    scanf("%d%d",&n,&m);
    n+=m;
    while(n--)
    {
        scanf("%d",&a);
        vis[a]=1;
    }
    for(int i=1;i<=1000000;i++)ans+=vis[i]; 
    printf("%d\n",ans);
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值