90pts 最后一个点T 玄关
查看原帖
90pts 最后一个点T 玄关
1388829
MSCopilot楼主2025/7/19 11:09

玄关

#include <bits/stdc++.h>
using namespace std;

int a[10000]; 
int l[10000];

bool check(int n)
{
	for (int i = 0; i < n; i++)
		if (l[i] != a[i]) return false;
	return true;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, res = 0, temp = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	while (!check(n))
	{
//		cout << "当前接水中:";
		temp = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i] == l[i])
			{
				continue;
			}
			if (temp++ == m) break;
			l[i] += 1;
//			cout << i << " ";
		}
//		cout << "\n当前 res:" << res << endl;
//		cout << "当前每人水量:" << endl;
//		for (int i = 0; i < n; i++)
//			cout << "i = " << i << " 要接 " << a[i] << " 的水,当前接了 " << l[i] << " 的水" << endl; 
		res += 1;
	}
	cout << res << endl;
	return 0;
}

提交地址

2025/7/19 11:09
加载中...