2022/9/17(cf·div2ECR135)https://codeforces.com/contest/1728

A题:https://codeforces.com/contest/1728/problem/A
//最大数量的牌一定可以成为答案

#include<bits/stdc++.h>
using namespace std;
#define int long long
int b[200005];

signed main()
{
	int tt;
	cin>>tt;
	while(tt--)
	{
		int n;
		cin>>n;
		int ans=0,p;
		for(int i=0;i<n;i++)
		{
			cin>>b[i];
			if(ans<b[i])
			{
				ans=b[i];
				p=i+1;
			}
		}
		cout<<p<<'\n';
	}
}


B题:https://codeforces.com/problemset/problem/1728/B
//最后两个数,一定是最大的两个数,n-1,n;
//和n-1比较的一定是0
//把剩余的数分两堆,一堆小的,一堆大的,分别配对;
//奇数个数时,会有数落单,把剩余的数的最中间一位排第一位,然后按大小,大小的排序;
//3 5 1 4 2 6 7
//5可以把3吸进去且不为0
//遇小为0,不影响我配对的目的

#include<bits/stdc++.h>
using namespace std;
#define int long long
int b[200005];

signed main()
{
	int tt;
	cin>>tt;
	while(tt--)
	{
		int n;
		cin>>n;
		if(n&1)cout<<n/2<<" ";
		int l=1,r=n-2;
		while(l<r)
		{
			cout<<r<<" "<<l<<" ";
			l++,r--;
		}
		cout<<n-1<<" "<<n;
		puts("");
	}
}


C题:https://codeforces.com/problemset/problem/1728/C
//模拟,看代码
//之前不会是因为不知道方法

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

signed main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//不用会超时
	int tt;
	cin>>tt;
	while(tt--)
	{
		int n;
		cin>>n;
		vector<int>v1(n),v2(n);
		for(int i=0;i<n;i++)
			cin>>v1[i];
		for(int i=0;i<n;i++)
			cin>>v2[i];
		
		priority_queue<int>q1(v1.begin(),v1.end());
		priority_queue<int>q2(v2.begin(),v2.end());
		
		int ans=0;
		
		while(q1.empty()==0)
		{
			if(q1.top()==q2.top())
			{
				q1.pop();q2.pop();
				continue;
			}
			ans++;
			if(q1.top()>q2.top())
			{
				q1.push(to_string(q1.top()).size());//求一个数的位数
				//等同于q1.push(log10(q1.top())+1);毛爷教的
				q1.pop();
			}
			else
			{
				q2.push(to_string(q2.top()).size());
				q2.pop();
			}
		}
		cout<<ans<<'\n';
	}
}

D我不会呀

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值