第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;
}