Codeforces Round #555 (Div. 3)

A

# include <bits/stdc++.h>
using namespace std;

typedef long long LL;
int f[10];
int main()
{
	LL n;
	LL sum=0;
	scanf("%lld",&n);
	LL nn=n;
	
	LL ans=0;
	while(1){
		LL m=nn/10*10+9;
		LL mm=m;
		LL d=0;
		while(mm){
			d++;
			mm=mm/10;
		}
		if(d==1){
			sum+=9;
			break;
		}
		int y=0;
		sum+=(m-nn+1);
		//cout<<(m-nn+1)<<endl;
		m=m+1;
		y=m%10;
		while(y==0){
			m=m/10;
			y=m%10;
		}
		nn=m;
	}
	printf("%lld",sum);
	
	return 0;
}

B

# include <bits/stdc++.h>
using namespace std;

typedef long long LL;
LL f[10];
int main()
{
	LL n;
	string a;
	
	scanf("%lld",&n);
	cin>>a;
	for(LL i=1;i<=9;i++){
		scanf("%lld",&f[i]);
	}
	int flag1=0;
	int l;
	for(LL i=0;i<a.length();i++){
		LL id=a[i]-'0';
		if(f[id]>=id){
			if(f[id]>id) flag1=1;
		//	flag1=1;
			printf("%lld",f[id]);
		}else{
			if(flag1){
				l=i;
				break;
			}
			printf("%lld",id);
		}
	}
	//cout<<l<<endl;
	for(LL i=l;i<a.length();i++){
		printf("%c",a[i]);
	}
	return 0;
}

C

# include <bits/stdc++.h>
using namespace std;

typedef long long LL;
list<LL> v; 
int main()
{
	LL n;
	string c="";
	scanf("%lld",&n);
	for(LL i=0;i<n;i++){
		LL a;
		scanf("%lld",&a);
		v.push_back(a);
	}
	LL ans=0;
	LL b=0;
	LL l=v.front();
	LL r=v.back();
	//cout<<l<<" "<<r<<endl;
	ans++;
	if(l<r){
		b=l;
		v.pop_front();
		c+='L';
	}else{
		b=r;
		v.pop_back();
		c+='R';
	}
	while(1){
		l=v.front();
	    r=v.back();
		//cout<<l<<" "<<r<<endl;
		if(l<r){
			if(l>b){
				b=l;
				v.pop_front();
				ans++;
				c+='L';
			}else{
				if(r>b){
					b=r;
					v.pop_back();
					ans++;
					c+='R';
				}else{
					break;
				}
			}
		}else{
			if(r>b){
				b=r;
				v.pop_back();
				ans++;
				c+='R';
			}else{
				if(l>b){
					b=l;
					v.pop_front();
					ans++;
					c+='L';
				}else{
					break;
				}
			}
		}
	}
	printf("%lld\n",ans);
	cout<<c;
	return 0;
}

E

# include <bits/stdc++.h>
using namespace std;
//multiset
const int MAXN=2e5+20;
const int MAXX=4e5+20;
int a[MAXN];
int b[MAXN];
int c[MAXN];
int f[MAXX];
int main()
{
	int n;
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		f[b[i]]++;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<n;j++){
			if((n+j-a[i])>=0&&f[n+j-a[i]]){
				f[n+j-a[i]]--;
				//cout<<n+j-a[i]<<" "<<j<<endl;
				printf("%d ",j);
				break;
			}
			if((j-a[i])>=0&&f[j-a[i]]){
				f[j-a[i]]--;
				//cout<<j-a[i]<<" "<<j<<endl;
				printf("%d ",j);
				break;
			}
		}
	}
	
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值