QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#696684#6695. Matchingpppwolf#WA 0ms3564kbC++23792b2024-11-01 00:27:222024-11-01 00:27:22

Judging History

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

  • [2024-11-01 00:27:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-11-01 00:27:22]
  • 提交

answer

#include <bits/stdc++.h>

using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;

void solve() {
	int n;
	std::cin >> n;
	std::vector<i64> a(n + 1);
	std::map<i64, std::vector<i64>> mp;
	for (int i = 1; i <= n; i++) {
		std::cin >> a[i];
		mp[a[i] - i].push_back(a[i]);
	}
	i64 ans = 0;
	for (auto [x, v] : mp) {
		if (v.size() < 2) {
			continue;
		}
		sort(v.begin(), v.end(), std::greater());
		for (int i = 0; i < v.size(); i += 2) {
			if (v[i + 1] + v[i] > 0) {
				ans += v[i + 1] + v[i]; 
			} else {
				break;
			}
		}
	}
	std::cout << ans << "\n";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int t; 
	std::cin >> t;
	while (t --) {
		solve();
	}

	return 0;
}

詳細信息

Test #1:

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

input:

3
9
3 -5 5 6 7 -1 9 1 2
3
-5 -4 -3
3
1 10 100

output:

101138
0
0

result:

wrong answer 1st numbers differ - expected: '30', found: '101138'