Codeforces Round #402 (Div. 2) A. Pupils Redistribution
来源:互联网 发布:腾讯红包数据 编辑:程序博客网 时间:2024/06/07 03:41
传送门
题目大意:求通过交换多少次使得两个组的相同数字的数量一样。
解题思路:水题。
/* ***********************************************┆ ┏┓ ┏┓ ┆┆┏┛┻━━━┛┻┓ ┆┆┃ ┃ ┆┆┃ ━ ┃ ┆┆┃ ┳┛ ┗┳ ┃ ┆┆┃ ┃ ┆┆┃ ┻ ┃ ┆┆┗━┓ 马 ┏━┛ ┆┆ ┃ 勒 ┃ ┆ ┆ ┃ 戈 ┗━━━┓ ┆┆ ┃ 壁 ┣┓┆┆ ┃ 的草泥马 ┏┛┆┆ ┗┓┓┏━┳┓┏┛ ┆┆ ┃┫┫ ┃┫┫ ┆┆ ┗┻┛ ┗┻┛ ┆************************************************ *///#pragma comment(linker, "/STACK:102400000,102400000")#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <bitset>using namespace std;#define rep(i,a,b) for (int i=(a),_ed=(b);i<=_ed;i++)#define per(i,a,b) for (int i=(a),_ed=(b);i>=_ed;i--)#define pb push_back#define mp make_pairconst int inf_int = 2e9;const long long inf_ll = 2e18;#define inf_add 0x3f3f3f3f#define mod 1000000007#define LL long long#define ULL unsigned long long#define MS0(X) memset((X), 0, sizeof((X)))#define SelfType intSelfType Gcd(SelfType p,SelfType q){return q==0?p:Gcd(q,p%q);}SelfType Pow(SelfType p,SelfType q){SelfType ans=1;while(q){if(q&1)ans=ans*p;p=p*p;q>>=1;}return ans;}#define Sd(X) int (X); scanf("%d", &X)#define Sdd(X, Y) int X, Y; scanf("%d%d", &X, &Y)#define Sddd(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())#define all(a) a.begin(), a.end()#define mem(x,v) memset(x,v,sizeof(x))typedef pair<int, int> pii;typedef pair<long long, long long> pll;typedef vector<int> vi;typedef vector<long long> vll;inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,rx=getchar();return ra*fh;}int a[10],b[10];int main(){//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);//ios::sync_with_stdio(0);//cin.tie(0);int n = read();for(int i=1;i<=n;i++) { int x = read(); a[x]++; }for(int i=1;i<=n;i++) { int x = read(); b[x]++; } int flag = 1; int ans = 0;for(int i=1;i<=5;i++) { int sum = a[i]+b[i]; if(sum%2!=0) { flag = 0; break; } sum /= 2; ans += abs(sum-a[i]); }if(!flag)puts("-1");else { printf("%d\n",ans/2); }return 0;}
0 0
- A. Pupils Redistribution -Codeforces Round #402 (Div. 2)
- Codeforces Round #402 (Div. 2) A. Pupils Redistribution
- Codeforces Round #402 (Div. 2) A. Pupils Redistribution
- Codeforces Round #402 (Div. 2) A. Pupils Redistribution
- Codeforces #402 (Div. 2) A. Pupils Redistribution
- (贪心)Codeforces Round #402 A. Pupils Redistribution
- Codeforces Round #402 (Div. 2) A. Pupils Redistribution(交换次数)
- Codeforces Round #402 (Div. 2) A.Pupils Redistribution 认真读题
- #402 (Div. 2)A. Pupils Redistribution
- 【Codeforces-402A】-Pupils Redistribution(思维)
- 【codeforces 779A】Pupils Redistribution
- Codeforces 779A-Pupils Redistribution
- Codeforces 778A. Pupils Redistribution
- CodeForces 779A Pupils Redistribution
- Pupils Redistribution (Codeforces-779A)
- 【CodeForces 779A】Pupils Redistribution(模拟)
- 【CodeForces 779A】Pupils Redistribution(模拟)
- 【CodeForces 779A】Pupils Redistribution(模拟)
- 如何在Android中集成支付宝
- 微信公众号【沈万三爱搬砖】的自述
- ElasticSearch 的 聚合(Aggregations)
- Try-with-resources (TWR)
- 浅谈中国计算机行业
- Codeforces Round #402 (Div. 2) A. Pupils Redistribution
- poj2187——Beauty Contest(凸包+旋转卡壳)
- sort函数用法
- python学习笔记(1):python的安装
- ZOJ3600-Taxi Fare
- PAT 1064
- Linux学习笔记(收藏的文章)
- Ubuntu:sudo apt-get upgrade升级失败
- 【洛谷P1204】【USACO1.2】挤牛奶Milking Cows