QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#614184#7964. 转化yzj123#WA 57ms19268kbC++201.8kb2024-10-05 15:50:392024-10-05 15:50:39

Judging History

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

  • [2024-10-05 15:50:39]
  • 评测
  • 测评结果:WA
  • 用时:57ms
  • 内存:19268kb
  • [2024-10-05 15:50:39]
  • 提交

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++)
	{
		int tcnt = cnt;
		ans = 0;
//		if (a[i] > 0 && b[i] > 0) tcnt--;
		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;
}

详细

Test #1:

score: 100
Accepted
time: 57ms
memory: 14580kb

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: 42ms
memory: 19268kb

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:

388926442 772736063 284712941 34822711 -169739 959846114 229990383 741978839 421987176 716309259 558961765 167197252 440347255 979741773 288644113 -169739 37456922 995280450 890324547 918791639 697029738 651590098 818279524 248403041 345516429 145652403 168899798 798225416 375078239 724349412 344862...

result:

wrong answer 1st lines differ - expected: '389246793 773056414 285033292 ...47596 273937941 15883376 150613', found: '388926442 772736063 284712941 ...245 273617590 15563025 -169739 '