csust-8.12早训CF之1000-1600分

目录

 

A - Straight «A»

B - Summer sell-off

C - Do you want a date?

D - Sagheer and Crossroads

E - Sagheer, the Hausmeister

F - Sagheer and Nubian Market


A - Straight «A»

 CodeForces - 810A 

题目链接https://codeforces.com/problemset/problem/810/A

//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define ll long long
const int inf = 4e8 + 10;
const int mac = 1e5 + 10;
int main()
{
	IOS;
	int n, m, x;
	cin >> n >> m;
	double sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		sum += x;
	}
	if (sum/n >= (double)m - 0.5) {
		cout << 0 << endl; return 0;
	}
	int p = 0;
	while (1) {
		n++; sum += m; p++;
		if (sum / n >= (double)m - 0.5) {
			cout << p << endl; return 0;
		}
	}
	return 0;
}

B - Summer sell-off

 CodeForces - 810B 

题目链接https://codeforces.com/problemset/problem/810/B

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define ll long long
const int inf = 4e8 + 10;
const int mac = 1e5 + 10;
struct node
{
	ll nb, ren;
}a[mac];
bool cmp(node a,node b)
{
	ll p=a.nb*2,p1=b.nb*2;
	if (p>a.ren) p=a.ren;
	if (p1>b.ren) p1=b.ren;
	return p-a.nb>p1-b.nb;
}
int main()
{
	IOS;
	int n, m, x, y;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].nb >> a[i].ren;
	}
	ll ans = 0;
	sort(a + 1, a + 1 + n,cmp);
	for (int i = 1; i <= n; i++) {
		if (m == 0) break;
		if (a[i].nb >= a[i].ren) continue;
		if (a[i].nb == 0) continue;
		else {
			m--; a[i].nb *= 2;
		}
	}
	for (int i = 1; i <= n; i++) {
		ans += (a[i].nb > a[i].ren) ? a[i].ren : a[i].nb;
	}
	cout << ans << endl;
	return 0;
}

C - Do you want a date?

 CodeForces - 810C 

题目链接https://codeforces.com/problemset/problem/810/C

D - Sagheer and Crossroads

 CodeForces - 812A 

题目链接https://codeforces.com/problemset/problem/812/A

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define ll long long
const int inf = 4e8 + 10;
const int mac = 2e5 + 10;
int l[10], r[10], s[10], p[10];
int main()
{
	IOS;
	int mark = 0;
	for (int i = 1; i <= 4; i++) {
		cin >> l[i] >> s[i] >> r[i] >> p[i];
	}
	for (int i = 1; i <= 4; i++) {
		if (p[i]) {
			if (i == 1) {
				if (l[1] || s[1] || r[1]) {
					cout << "YES" << endl; return 0;
				}
				if (r[4] || l[2] || s[3]) {
					cout << "YES" << endl; return 0;
				}
			}
			else if (i == 2) {
				if (l[2] || s[2] || r[2]) {
					cout << "YES" << endl; return 0;
				}
				if (r[1] || l[3] || s[4]) {
					cout << "YES" << endl; return 0;
				}
			}
			else if (i == 3) {
				if (l[3] || s[3] || r[3]) {
					cout << "YES" << endl; return 0;
				}
				if (r[2] || l[4] || s[1]) {
					cout << "YES" << endl; return 0;
				}
			}
			else {
				if (l[4] || s[4] || r[4]) {
					cout << "YES" << endl; return 0;
				}
				if (r[3] || l[1] || s[2]) {
					cout << "YES" << endl; return 0;
				}
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

E - Sagheer, the Hausmeister

 CodeForces - 812B 

题目链接https://codeforces.com/problemset/problem/812/B

F - Sagheer and Nubian Market

 CodeForces - 812C 

题目链接https://codeforces.com/problemset/problem/812/C

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值