Educational Codeforces Round 100 (Rated for Div. 2)A-C

第100场Edu,挺有纪念意义
战况:
在这里插入图片描述在这里插入图片描述
rating+79
还是个pupil(挠头)
有想一起打CF的朋友可以加我qq:942845546,共同进步,共同上分,欢迎骚扰(手动滑稽)。

这一场在A,B上浪费了不少时间,还加了三十分钟罚时(笑哭),导致C题看出解法最后没打完,说到底还是码力不行,水平太菜。
题面太长,请点击Educational Codeforces Round 100 (Rated for Div. 2)
A.Dungeon
思路:当满足a+b+c>=9并且a+b+c的和为9的倍数且(a+b+c)/9大于min(a,b,c)时可以满足条件。(个人感觉这个第一题难度比以往的第一题略高)

#include <bits/stdc++.h>
using namespace std;
int t;
long long a, b, c;
int main(){
	scanf("%d", &t);
	while(t--){
		scanf("%lld%lld%lld", &a, &b, &c);
		long long d = min(a, min(b, c));
		if((a + b + c) % 9 == 0 && (a + b + c) / 9 <= d && a + b + c >= 9) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
} 

B.Find The Array
思路:两种构造,一种为奇数项为1,偶数项为原数,另一种为偶数项为1,奇数项为原数。显然,一定有一种情况是完美满足条件的。

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

int t, n;
long long a[61], b[61];
int main(){
	scanf("%d", &t);
	while(t--){
		long long sum = 0, summ = 0;
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%lld", &a[i]);
			sum += a[i];
		}
		for(int i = 1; i <= n; i++){
			if(i % 2 == 1) summ += abs(a[i] - 1);
		}
		if(2 * summ <= sum){
			for(int i = 1; i <= n; i++){
				if(i % 2 == 1) printf("1 ");
				else printf("%lld ", a[i]);
			}
		}
		else{
			for(int i = 1; i <= n; i++){
				if(i % 2 == 0) printf("1 ");
				else printf("%lld ", a[i]);
			}
		}
		printf("\n");
	}
	return 0;
} 

C.Busy Robot
思路:先模拟出在每一个给出的时间时的位置,再用xi和两边进行判断。(这道题挺考验码力的,比赛时写完第一遍有bug,已经没时间再改了)

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

int t, n;
ll a[100010], b[100010], c[100010];

int main(){
	scanf("%d", &t);
	while(t--){
		ll x = 0, temp = 0, ans = 0;
		scanf("%d", &n);
		for(int i = 1; i <= n; i++){
			scanf("%lld%lld", &a[i], &b[i]);
		}
		a[n + 1] = 2e10 + 1;
		for(int i = 1; i <= n + 1; i++){
			c[i] = x;
			//printf("%lld %lld \n", c[i], temp);
			if(temp == 0){
					temp = b[i] - x;
					if(temp > 0){
						if(temp >= a[i + 1] - a[i]){
							x += a[i + 1] - a[i];
							temp -= a[i + 1] - a[i];
						} 
						else{
							x += temp;
							temp = 0;
						} 
					}
					else if(temp < 0){
						if(temp + a[i + 1] - a[i] <= 0){
							x -= a[i + 1] - a[i];
							temp += a[i + 1] - a[i];
						}
						else{
							x += temp;
							temp = 0;
						} 
					}	
			}
			else{
				if(temp > 0){
						if(temp >= a[i + 1] - a[i]){
							x += a[i + 1] - a[i];
							temp -= a[i + 1] - a[i];
						} 
						else{
							x += temp;
							temp = 0;
						} 
					}
					else if(temp < 0){
						if(temp + a[i + 1] - a[i] <= 0){
							x -= a[i + 1] - a[i];
							temp += a[i + 1] - a[i];
						}
						else{
							x += temp;
							temp = 0;
						} 
					}
			}
			
		}
		for(int i = 1; i <= n; i++){
			if(b[i] >= min(c[i], c[i + 1]) && b[i] <= max(c[i], c[i + 1])) ans++;
		}
		printf("%lld\n", ans);
	}
	return 0;
}
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值