【Codeforces】CodeTON Round 4 (Div. 1 + Div. 2, Rated, Prizes!) (补赛)

Beautiful Sequence

题目大意 :

解题思路:

参考代码:


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int T, n;
int a[N];
void slove() {
	cin >> n;
	int ok = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] <= i) ok = 1;
	}
	if (ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}
int main() {
	cin >> T;
	while (T--) slove();
	return 0;
}

Candies

题目大意:

解题思路:

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
ll T, n;
vector<int>ans;
int cnt;
void slove() {
	cin >> n;
	if (n % 2 == 0) cout << -1 << endl;
	else {
		cnt = -1;
		ans.clear();
		while (n) {
			cnt++;
			if (n % 2 == 1)ans.push_back(2);
			else ans.push_back(1);
			n /= 2;
		}
		cout << cnt << endl;
		for (int i=ans.size()-1;i>=1;i--) cout << ans[i] << ' ';
		cout << endl;
	}
}
int main() {
	cin >> T;
	while (T--) slove();
	return 0;
}

Make It Permutation

题目大意:

解题思路:

参考代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
ll T, n, c, d;
ll cnt, x;
unordered_map<int, bool>mp;
vector<int>key;
void slove() {
	cin >> n >> c >> d;
	cnt = 0;
	mp.clear();
	key.clear();
	key.push_back(0);
	for (int i = 1; i <= n; i++) {
		cin >> x;
		if (mp[x]) cnt += c;
		else mp[x] = 1, key.push_back(x);
	}
	ll ans = 2e18;
	ll len = mp.size();
	sort(key.begin(), key.end());
	for (int i = 1; i <= len; i++) {
		ans = min(ans, (key[i] - i) * d + (len - i) * c);
	}
	ans = min(ans, d + len * c);
	cout << ans + cnt << endl;
}
int main() {
	cin >> T;
	while (T--) slove();
	return 0;
}

D

题目大意:

解题思路:

参考代码:

E

F

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值