QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#614267#8743. 转化yzj12345WA 0ms9660kbC++201.7kb2024-10-05 16:03:152024-10-05 16:03:18

Judging History

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

  • [2024-10-05 16:03:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:9660kb
  • [2024-10-05 16:03:15]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int res = 0, bj = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		if (ch == '-') bj = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		res = res * 10 + ch - '0';
		ch = getchar();
	}
	return res * bj;
}
const int MAXN = 351493 + 5;
int n, ans, a[MAXN], b[MAXN], c[MAXN];
int p[MAXN], sump;
signed main()
{
	n = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	for (int i = 1; i <= n; i++) b[i] = read();
	for (int i = 1; i <= n; i++) c[i] = read();
	//统计有球且能转化的
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (a[i] > 0 && b[i] > 0) cnt++; 
	for (int i = 1; i <= n; i++)
	{
		if (a[i] == 0) p[i] = min(c[i], b[i] - 1);
		else p[i] = min(a[i] + c[i], b[i]);
		sump += p[i];
	}		
	for (int i = 1; i <= n; i++)
	{
		ans = 0;
		if (cnt > 0) ans = sump - p[i] + a[i] + c[i];  
		else 
		{
			if (a[i] == 0) ans = 0;
			else ans = a[i] + c[i];
		}
		cout << ans << " ";
	}
	cout << "\n"; 
	ans = 0;
	if (cnt == 0)
	{	
		for (int i = 1; i <= n; i++)
			if (a[i] > 0) ans += a[i] + c[i];
	}
	else 
	{
		//统计有多少个可以转化的球 
		int num = 0;
		for (int i = 1; i <= n; i++) 
		{
			if (a[i] == 0) num += min(b[i] - 1, c[i]);
			else num += min(b[i], a[i] + c[i]);
		}
		//统计不能转化的
		vector<int> v;
		for (int i = 1; i <= n; i++)
			if (a[i] == 0 && b[i] == 0) v.push_back(c[i]);
		sort(v.begin(), v.end(), [](int x, int y) {
			return x > y;
		});
		for (int i = 0; i < min((int)v.size(), num); i++) ans += v[i];
		for (int i = 1; i <= n; i++)
			if (a[i] != 0 || b[i] != 0) ans += a[i] + c[i];
	}
	cout << ans;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 9660kb

input:

100 1000
327 833 558 253 722 710 811 779 789 919 750 288 611 674 670 264 815 701 304 615 9 943 713 633 392 706 687 847 78 999 368 55 913 61 686 512 696 0 695 285 485 877 533 54 621 925 339 319 597 536 285 701 186 933 234 360 284 546 545 185 112 735 147 851 824 512 695 734 237 381 777 449 880 675 614...

output:

5280 4680 5128 4918 4626 4971 5087 5142 5115 5161 5253 5069 4590 4990 5061 4984 4602 5148 5051 4600 4918 4318 5297 5123 4911 4681 5045 5015 5153 4369 5274 4695 4349 5223 4328 5033 4889 5000 4318 4997 4575 4731 5183 4864 4339 4990 5197 4690 4645 4973 4868 4537 5041 4517 5230 4560 4756 4661 4936 4930 ...

result:

wrong answer 1st lines differ - expected: '2155053232761438', found: '5280 4680 5128 4918 4626 4971 ... 4344 4493 4486 5022 4754 4586 '