Round 1201 (Codeforces Round #577(div.2)) 题解

Problem A

problem meaning

There are n students and m test questions. Each test question has a score ai. Every student answered every question (the answers only exist in A, B, C, D, E). They don’t know the correct answer. Ask what is the student’s total score in the best case.

Thinking

Violence is enough. For each test question, enumerate all possible answers, calculate the total score of all students for that question, and take the largest one and add it to the total answer.

# include # define rr registerconst int N=1010;int n,m;int val[N];char a[N][N]; char ans[10]={'','A','B','C','D','E'};int sum;int main(void){ scanf("%d%d",&n ,&m); for(rr int i=1;i<=n;++i){ for(rr int j=1;j<=m;++j){ std::cin>>a[i] [j];}} for(rr int i=1;i<=m;++i){ scanf("%d",&val[i]);} for(rr int i=1,maxx,tmp; i<=m;++i){ maxx=-1e9; for(rr int k=1;k<=5;++k){ tmp=0; for(rr int j=1;j<=n; ++j){ if(a[j][i]==ans[k]){ tmp+=val[i];}} maxx=std::max(maxx,tmp);} sum+=maxx;} printf ("%d",sum); return 0;}

Problem B

题意

Give you an array of length n, the array elements are all positive integers. You can select two different elements each time and reduce them by 1. Asked whether after several operations can the elements of the entire array become 0.

Thinking

The nightmare begins... This question was handed in 3 times before I passed it, and I was fined 100 points. Distressed

First of all, if the sum of the entire array is odd, it must not work. Because each operation will reduce the sum of the array elements by 2, if the sum of the array elements is required to be 0, then the original array sum is odd (odd-even = odd).

In addition, if the largest element in the array is greater than the sum of other elements, it is also not allowed. Because when all other elements become 0, the largest element cannot become 0.

# include 
# define rr register
# define int long long
const int N=200010;
int a[ N];
int b[N];
int sum;
int n;
signed main(void){
scanf("%I64d",&n) ;
for(rr int i=1;i<=n;++i){
scanf("%I64d",&a[i]);
sum+=a[i] ;
}
std::sort(a+1,a+1+n);
if(sum%2||a[n]>(sum-a[n]) ){
printf("NO");
return 0;
}else{
printf("YES");
return 0;
}
return 0;
}

Problem C

(Writing in the morning. Go to bed first)

< h2 id="problem-de1e2">Problem D,E1,E2

I didn’t even look at it. too difficult.

Leave a Comment

Your email address will not be published.