QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#183676 | #6695. Matching | liuzhenhao09# | RE | 0ms | 0kb | C++14 | 569b | 2023-09-19 19:11:51 | 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