为啥错了2个点。。。。
查看原帖
为啥错了2个点。。。。
172240
kuaiCreator楼主2024/12/18 22:16
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll,int>
using namespace std;
const int N = 2e5 + 5;
char ch[N];
ll n, t, p[5], s;
priority_queue<pii> q;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> t;
		s += t;
		q.push(make_pair(t, i));
	}
	while (q.size()) {
		int wi = q.top().first;
		int id = q.top().second;
		q.pop();
		ll j, mi = 1e18;
		for (int i = 1; i <= 3; i++)
			if (mi > p[i]) {
				mi = p[i];
				j = i;
			}
		p[j] += wi;
		if (p[j] >= s / 2) {
			cout << "Internationale!";
			return 0;
		}
		if (j == 1) ch[id] = 'B';
		else if (j == 2) ch[id] = 'Y';
		else ch[id] = 'Z';
	}
	for (int i = 1; i <= n; i++)
		cout << ch[i];
	return 0;
}
2024/12/18 22:16
加载中...