QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#183676#6695. Matchingliuzhenhao09#RE 0ms0kbC++14569b2023-09-19 19:11:512023-09-19 19:11:51

Judging History

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

  • [2023-09-19 19:11:51]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-09-19 19:11:51]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,n;
int a[100010],b[100010];
vector<int>to[100010];
signed main(){
	scanf("%lld",&T);
	while(T--){
		scanf("%lld",&n);
		set<int>s;
		for(int i = 1; i <= n; i++) scanf("%lld",&a[i]),b[i] = a[i] - i,to[b[i]].push_back(i),s.insert(b[i]);
		int sum = 0;
		for(auto v : s){
			for(int i = to[v].size() - 1; i >= 1; i -= 2){
				int val = a[to[v][i]] + a[to[v][i - 1]];
				if(val > 0) sum += val;
			}
		}
		printf("%lld\n",sum);
		for(auto v : s) to[v].clear();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

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

output:


result: