957 div3

A

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int a, b, c;

int main()
{
	int test;
	cin >> test;
	while(test --)
	{
		priority_queue <int, vector<int>, greater<int> > hp;
		cin >> a >> b >> c;
		hp.push(a);
		hp.push(b);
		hp.push(c);
		for (int i = 0; i < 5; i ++)
		{
			int x = hp.top();
			hp.pop();
			x ++;
			hp.push(x);	
		}
		int res = 1;
		
		while(!hp.empty())
		{
			int x = hp.top();
			res = res * x;
			hp.pop();
		}
		
		cout << res << endl;
	}
	return 0;
	
	
}

B

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10;
int n, k;
int pot[N];

int main()
{
	int test;
	cin >> test;
	while(test --)
	{
		cin >> n >> k;
		for (int i = 1; i <= k; i ++)	cin >> pot[i];
		
		sort(pot + 1, pot + 1 + k);
		
		long long res = 0;
		long long sum = 0;
		
		for (int i = 1; i < k; i ++)
		{
			int x = pot[i];
			if(x == 1)
			{
				res ++;
				continue;
			}
			
			res = res + x - 1 + x;
		}
		
		cout << res << endl;
	}
	
	return 0;
	
	
}

C

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const int N = 2e5 + 10;
int n, m, k;

int main()
{
	int test;
	cin >> test;
	while(test --)
	{
		cin >> n >> m >> k;
		vector<int> res(n, 0);
		int h = max(m, k), l = min(m, k);
		int idx = 0;
		for (int i = n; i > l; i --)
		 res[idx ++] = i;
		for (int i = 1; i <= l; i ++)
			res[idx ++] = i;
			
		for (int  i = 0; i < n; i ++)	cout << res[i] << " ";
		cout << endl; 
	}
	
	return 0;
	
	
}

D


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const int N = 2e5 + 10;
int n, m, k;
char river[N];

int main()
{
	int test;
	cin >> test;
	while(test --)
	{
		cin >> n >> m >> k;
		for (int i = 1; i <= n; i ++)	cin >> river[i];
		
		vector<int> wood;
		wood.push_back(0);
		for (int i = 1; i <= n; i ++)
			if(river[i] == 'L')
				wood.push_back(i);
		wood.push_back(n + 1);
		
		int cold = 0;
		bool f = true;
		
		for (int i = 0; i < (int)wood.size() - 1 && f && cold <= k; i ++)
		{
			int x = wood[i], y = wood[i + 1];
			if(y - x <= m)	continue;
			
			int far = -1;
			for(int j = x + 1; j <= x + m; j ++)
				if(river[j] == 'W')	far = max(far, j);
			
			if(far == -1) {f = 0; break;}
			cold ++;
			for (int j = far + 1; j < y; j ++)
			{
				if(river[j] == 'C')
				{
					f = false;
					break;
				}
				else	cold ++;
			
			}
			
		}
		
		if(cold > k || f == false)	cout << "NO" << endl;
		else	cout << "YES" << endl;
		
		//cout << res << endl;
	}
	
	return 0;
	
	
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值