当前位置:   article > 正文

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

educational codeforces round 100 (rated for div. 2)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;
} 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

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;
} 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

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;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/55023?site
推荐阅读
相关标签
  

闽ICP备14008679号