QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#300827#7964. 转化defyers#WA 125ms24868kbC++201.8kb2024-01-08 21:14:012024-01-08 21:14:01

Judging History

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

  • [2024-01-08 21:14:01]
  • 评测
  • 测评结果:WA
  • 用时:125ms
  • 内存:24868kb
  • [2024-01-08 21:14:01]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

using ll = long long;
using LL = long long;

#define int long long
const int N = 4e5 + 11;
int a[N], b[N], c[N];

int f(int x){
	return min(b[x], a[x] + c[x] + 1);
}

void solve(int TC) {
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) cin >> c[i];

	for(int i = 0; i < n; i++){
		if(a[i]) a[i] += c[i], c[i] = 0;
	}
	
	int free_ball = 0;
	for(int i = 0; i < n; i++){
		int x = min(a[i], b[i]);
		a[i] -= x; b[i] -= x;
		free_ball += x;
	}

	if(!free_ball){
		for(int i = 0; i < n; i++){
			cout << a[i] << " \n"[i == n - 1];
		}
		int s = accumulate(a, a + n, 0LL);
		cout << s << '\n';
		return;
	}

	int s = 0; for(int i = 0; i < n; i++) s += f(i);
	for(int i = 0; i < n; i++){
		cout << free_ball + a[i] + c[i] + s - f(i) << " \n"[i == n - 1];
	}
	
	int ans = 0;
	priority_queue<pair<pair<int, int>, int>> pq;
	for(int i = 0; i < n; i++){
		pq.push({{min(b[i], a[i] + c[i] + 1), c[i]}, i});
	}
	// cout << free_ball << '\n';
	// for(int i = 0; i < n; i++){
	// 	cout << a[i] << ' ';
	// }
	// cout << '\n';

	// for(int i = 0; i < n; i++){
	// 	cout << b[i] << ' ';
	// }
	// cout << '\n';

	// for(int i = 0; i < n; i++){
	// 	cout << c[i] << ' ';
	// }
	// cout << '\n';

	while(!pq.empty() && free_ball > 0){
		auto [p, i] = pq.top(); pq.pop();
		a[i] += c[i] + 1; free_ball--;
		int x = min(a[i], b[i]);
		a[i] -= x; free_ball += x;
	}
	ans += accumulate(a, a + n, 0LL);
	ans += free_ball;
	cout << ans << '\n';
}

int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	cout << fixed << setprecision(10);

	int t = 1;
	// cin >> t;

	for (int i = 1; i <= t; i++) {
		solve(i);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 125ms
memory: 24868kb

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:

60073965225211 60073472551692 60073472551691 60073481903189 60073472551692 60073788912817 60073528304052 60073472551692 60073844534151 60073784354640 60073472551691 60073472551691 60073948841472 60073472551691 60073472551691 60073667360933 60073550509417 60073472551692 60073631723817 60073472551692 ...

result:

wrong answer 1st lines differ - expected: '60073965049724 60073472376204 ...4 60073701685447 60073472376204', found: '60073965225211 60073472551692 ...1 60073701860934 60073472551691'