杜绝0索引,从你他她它做起——警钟长鸣
查看原帖
杜绝0索引,从你他她它做起——警钟长鸣
521554
Wing_Din_Gaster楼主2025/1/18 15:09

如题。

45pts直角vs100 All accept

只在一念之间

45pts:

#include <bits/stdc++.h>
using namespace std;
const long long INVALID = LLONG_MIN, MAXN = 1e5;
long long n, m, q, u, v, t, i, tp[4], p, a[MAXN + 1], delta = 0, theTrueP;
queue<long long> que[4];
inline int MinistT()
{
	if (tp[1] >= tp[2])
		if (tp[1] >= tp[3])
			return 1;
		else
			return 3;
	else
		if (tp[2] >= tp[3])
			return 2;
		else
			return 3;
}
signed main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	// freopen("P2827_6.in", "r", stdin), freopen("P2827_6.out", "w", stdout);
	cin >> n >> m >> q >> u >> v >> t;
	for (i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	for (i = 0; i < n; ++i)
		que[1].push(a[i]);
	for (i = 0; i < m; ++i)
	{
		// cerr << "i = " << i << ":\n";
		tp[1] = INVALID, tp[2] = INVALID, tp[3] = INVALID, p = INVALID;
		if (!que[1].empty())
			tp[1] = que[1].front();
		if (!que[2].empty())
			tp[2] = que[2].front();
		if (!que[3].empty())
			tp[3] = que[3].front();
	if (tp[1] >= tp[2] && tp[1] >= tp[3])
			que[1].pop(), p = tp[1];
		else if (tp[2] > tp[1] && tp[2] >= tp[3])
			que[2].pop(), p = tp[2];
		else
			que[3].pop(), p = tp[3];
		theTrueP = p + delta;
		delta += q;
		que[2].push(theTrueP * u / v - delta), que[3].push(theTrueP - theTrueP * u / v - delta);
		if (i % t == 0)
			cout << theTrueP << ' ';
	}
	cout << endl;
	for (i = 0; i < n + m; ++i)
	{
		tp[1] = INVALID, tp[2] = INVALID, tp[3] = INVALID, p = INVALID;
		if (!que[1].empty())
			tp[1] = que[1].front();
		if (!que[2].empty())
			tp[2] = que[2].front();
		if (!que[3].empty())
			tp[3] = que[3].front();
		if (tp[1] >= tp[2] && tp[1] >= tp[3])
			p = tp[1], que[1].pop();
		else if (tp[2] > tp[1] && tp[2] >= tp[3])
			p = tp[2], que[2].pop();
		else
			p = tp[3], que[3].pop();
		if (i % t == 0)
			cout << p + delta << ' ';
	}
	cout << endl;
	return 0;
}

100pts:

#include <bits/stdc++.h>
using namespace std;
const long long INVALID = LLONG_MIN, MAXN = 1e5;
long long n, m, q, u, v, t, i, tp[4], p, a[MAXN + 1], delta = 0, theTrueP;
queue<long long> que[4];
inline int MinistT()
{
	if (tp[1] >= tp[2])
		if (tp[1] >= tp[3])
			return 1;
		else
			return 3;
	else
		if (tp[2] >= tp[3])
			return 2;
		else
			return 3;
}
signed main()
{
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	// freopen("P2827_6.in", "r", stdin), freopen("P2827_6.out", "w", stdout);
	cin >> n >> m >> q >> u >> v >> t;
	for (i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	for (i = 0; i < n; ++i)
		que[1].push(a[i]);
	for (i = 1; i <= m; ++i)
	{
		// cerr << "i = " << i << ":\n";
		tp[1] = INVALID, tp[2] = INVALID, tp[3] = INVALID, p = INVALID;
		if (!que[1].empty())
			tp[1] = que[1].front();
		if (!que[2].empty())
			tp[2] = que[2].front();
		if (!que[3].empty())
			tp[3] = que[3].front();
		if (tp[1] >= tp[2] && tp[1] >= tp[3])
			que[1].pop(), p = tp[1];
		else if (tp[2] > tp[1] && tp[2] >= tp[3])
			que[2].pop(), p = tp[2];
		else
			que[3].pop(), p = tp[3];
		theTrueP = p + delta;
		delta += q;
		que[2].push(theTrueP * u / v - delta), que[3].push(theTrueP - theTrueP * u / v - delta);
		if (i % t == 0)
			cout << theTrueP << ' ';
	}
	cout << endl;
	for (i = 1; i <= n + m; ++i)
	{
		tp[1] = INVALID, tp[2] = INVALID, tp[3] = INVALID, p = INVALID;
		if (!que[1].empty())
			tp[1] = que[1].front();
		if (!que[2].empty())
			tp[2] = que[2].front();
		if (!que[3].empty())
			tp[3] = que[3].front();
		if (tp[1] >= tp[2] && tp[1] >= tp[3])
			p = tp[1], que[1].pop();
		else if (tp[2] > tp[1] && tp[2] >= tp[3])
			p = tp[2], que[2].pop();
		else
			p = tp[3], que[3].pop();
		if (i % t == 0)
			cout << p + delta << ' ';
	}
	cout << endl;
	return 0;
}
2025/1/18 15:09
加载中...