201909-1 小明种苹果

试题编号: 201909-1
试题名称: 小明种苹果
时间限制: 2.0s
内存限制: 512.0MB

201909-1 小明种苹果_第1张图片

201909-1 小明种苹果_第2张图片

        思路很简单,求和、相减、比较......

int main()
{
	int N = 0, M;
	cin >> N >> M;
	vectorHave(N+1);
	vectorDrop(N + 1);
	long long Sum = 0;
	int index = 0, drop_max = 0;
	for (int i = 1; i <= N; ++i) {
		cin >> Have[i];
		Drop[i] = 0;
		for (int j = 0; j < M; ++j) {
			int save;
			cin >> save;
			Drop[i] -= save;
		}
		if (Drop[i] > drop_max) {
			index = i;
			drop_max = Drop[i];    // 找出疏果次数最多的
		}
		//cout << Have[i] << ' ' << Drop[i] << endl;
		Sum += Have[i] - Drop[i];    //求剩余苹果数之和
		//cout << "SuM = " << Sum << endl;
	}
	cout << Sum << ' '<< index << ' ' << Drop[index];
	return 0;
}

 

你可能感兴趣的:(CSP,认证)