CodeForces 519C A and B and Team Training

A and B are preparing themselves for programming contests.

An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.

A believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.

However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.

As a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.

There are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?

Print the maximum number of teams that can be formed.
知道题意后表示。。。没看题真后悔!!!

什么时候c题变得这么容易。。。。。

思路看代码

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main() {
	int n, m;
	scanf ("%d %d", &n, &m);
	if (n > m * 2) {
		printf ("%d\n", m);
	} else if (m > n * 2) {
		printf ("%d\n", n);
	} else {
		printf ("%d\n",(n + m) / 3);
	}
	system ("pause");
}

猜你喜欢

转载自blog.csdn.net/yvvvvy/article/details/80372042
今日推荐