QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#614256#7964. 转化lymWA 133ms22248kbC++202.0kb2024-10-05 16:01:182024-10-05 16:01:18

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 16:01:18]
  • 评测
  • 测评结果:WA
  • 用时:133ms
  • 内存:22248kb
  • [2024-10-05 16:01:18]
  • 提交

answer

#include<bits/stdc++.h>
using i64 = long long;
#define int i64
void solve() {
	int n;
	std::cin >> n;
	std::vector<std::array<int, 4> > a(n + 1);
	std::vector<int> e(n + 1);
	for (int i = 1; i <= n; i ++) {
		std::cin >> a[i][0];
	}
	for (int i = 1; i <= n; i ++) {
		std::cin >> a[i][1];
	}
	for (int i = 1; i <= n; i ++) {
		std::cin >> a[i][2];
		a[i][3] = i;
	}
	i64 sum = 0, res = 0;
	for (int i = 1; i <= n; i ++) {
		if (a[i][0] && a[i][1]) {
			e[a[i][3]] = 1;
			sum += a[i][0] + a[i][2];
			res += std::min(a[i][0] + a[i][2], a[i][1]);
		}
	}
	std::sort(a.begin() + 1, a.end(), [&](auto x, auto y) {
		return x[1] > y[1];
	});
	for (int i = 1; i <= n; i ++) {
		if (e[a[i][3]] || a[i][1] == 0) continue;
		sum += a[i][2];
		res --;
		res += std::min(a[i][2] + 1ll, a[i][1]);
	}
	std::vector<int> b;
	for (int i = 1; i <= n; i ++) {
		if (e[a[i][3]] || a[i][1] != 0) continue;
		b.push_back(a[i][0] + a[i][2]);
	}
	std::sort(b.begin(), b.end(), [&](auto x, auto y) {
		return x > y;
	});
	for (auto it : b) {
		if (res) {
			sum += it;
			res --;
		} else {
			break;
		}
	}

	std::vector<int> d(n + 1);
	i64 op = 0;
	res = 0;
	for (int i = 1; i <= n; i ++) {
		if (a[i][0] && a[i][1]) {
			d[a[i][3]] = std::min(a[i][1], a[i][0] + a[i][2]);
			op += d[a[i][3]];
		}
	}
	int min = 1e18;
	for (int i = 1; i <= n; i ++) {
		if (e[a[i][3]] || a[i][1] == 0) continue;
		op --;
		d[a[i][3]] = std::min(a[i][2] + 1ll, a[i][1]) - 1;
		op += std::min(a[i][2] + 1ll, a[i][1]);

		min = std::min(min, d[a[i][3]]); // 获 1
	}
	std::sort(a.begin() + 1, a.end(), [&](auto x, auto y) {
		return x[3] < y[3];
	});
	for (int i = 1; i <= n; i ++) {
		if (a[i][0] || a[i][1]) {
			std::cout << a[i][0] + a[i][2] + op - d[i] << ' ';
		} else {
			std::cout << std::max(op, op - min + a[i][0] + a[i][2]) << ' ';
		}
	}
	std::cout << '\n';
	std::cout << sum << '\n';
}
signed main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int t = 1;
	//std::cin >> t;
	while (t --) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 133ms
memory: 19656kb

input:

351493
0 37836791 46095966 46912389 21595941 0 3 86568894 3 0 0 0 0 39910208 0 2 4 86885825 1 67660833 0 24488082 52447896 0 67190942 70457491 11166998 90470470 11095822 0 0 5 47222930 2 49736354 0 0 0 77339472 0 5 3 0 25347727 0 3 2 0 48844622 0 65142757 1 73733079 80634668 46683173 0 31644647 9760...

output:

60073965049724 60073472376204 60073472376204 60073481727701 60073472376204 60073788737330 60073528128564 60073472376204 60073844358663 60073784179153 60073472376204 60073472376204 60073948665985 60073472376204 60073472376204 60073667185445 60073550333929 60073472376204 60073631548329 60073472376204 ...

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 98ms
memory: 22248kb

input:

351493
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613 150613...

result:

wrong answer 1st lines differ - expected: '389246793 773056414 285033292 ...47596 273937941 15883376 150613', found: '150613 150613 150613 150613 15...13 150613 150613 150613 150613 '