临时改时间了结果我失了智打了后半场……rk2700全程被碾压

A. Left-handers, Right-handers and Ambidexters

一道略微简单的题

答案讨论下左右撇子哪个多就行,不够就Ambidexters凑,Ambidexters还有剩余就一边分一个

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<iterator>
#include<cstdlib>
#include<queue>
using namespace std;

int l,r,a,ans;

int main()
{
	scanf("%d%d%d",&l,&r,&a);
	if (l==r) ans=l+r+(a/2)*2;
	else if (l<r)
	{
		int cache=min(a,r-l);
		l+=cache; a-=cache;
		r=min(l,r);
		ans=l+r+(a/2)*2;
	}
	else
	{
		int cache=min(a,l-r);
		r+=cache; a-=cache;
		l=min(l,r);
		ans=l+r+(a/2)*2;
	}
	printf("%d\n",ans);
	return 0;
}

B. Intercepted Message

贪心.两边取,相等就消掉,不相等继续取

#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<iterator>
#include<cstdlib>
#include<queue>
using namespace std;

long long lena,lenb,a[100010]={0},b[100010]={0};
long long ans=0,ca=0,cb=0;

inline void readx(long long& x)
{
	x=0; long long k=1; register char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}

int main()
{
	readx(lena); readx(lenb);
	for (int i=1;i<=lena;i++) readx(a[i]);
	for (int i=1;i<=lenb;i++) readx(b[i]);
	
	int posa=0,posb=0;
	while (posa<=lena && posb<=lena)
	{
		if (posa==lena && posb==lenb) break;
		posa++; posb++;
		ca+=a[posa]; cb+=b[posb];
		while (ca!=cb)
		{
			if (ca<cb) { posa++; ca+=a[posa]; }
			else { posb++; cb+=b[posb]; }
		}
		ans++; ca=cb=0;
	}
	
	printf("%lld\n",ans);
	return 0;
}

C. Zebras

从前往后扫,vector维护序列们

每次维护两个集合,末尾是0的序列的集合,和末尾是1的,如果空了就新建序列

但是如果末尾是0的序列的集合空了而还有1的话不就无解了嘛

D. A Leapfrog in the Array

留坑

分类: Codeforces

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.