QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#640567 | #6695. Matching | Lautisticyc | WA | 63ms | 8796kb | C++14 | 662b | 2024-10-14 14:20:32 | 2024-10-14 14:20:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int cas,n,a[100010],cnt;
long long ans;
map<int,int> id;
vector<int> vec[100010];
int main()
{
scanf("%d",&cas);
while(cas--)
{
scanf("%d",&n);
cnt=0;
ans=0;
for(int i=1;i<=n;++i)
{
scanf("%d",&a[i]);
a[i]-=i;
if(!id[a[i]])
{
id[a[i]]=++cnt;
vec[cnt].clear();
}
vec[id[a[i]]].push_back(i);
}
for(int i=1;i<=cnt;++i)
{
while(vec[i].size()>=2)
{
int b=vec[i].back();
vec[i].pop_back();
int c=vec[i].back();
vec[i].pop_back();
if(b+c+a[b]*2>=0) ans+=b+c+a[b]*2;
}
}
printf("%lld\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6380kb
input:
3 9 3 -5 5 6 7 -1 9 1 2 3 -5 -4 -3 3 1 10 100
output:
30 0 0
result:
ok 3 number(s): "30 0 0"
Test #2:
score: -100
Wrong Answer
time: 63ms
memory: 8796kb
input:
5504 9 -1 -7 -6 -5 -4 -3 5 -1 0 5 999999995 999999993 999999995 999999995 999999995 5 3 -6 -5 -4 -2 4 -8 2 3 -5 4 -2 -1 0 1 9 -4 -9 3 -1 -1 -5 2 -3 -5 7 -1 -2 1 2 3 4 3 4 -2 5 2 -4 10 2 4 1 -3 -2 4 5 -3 0 -4 6 -1 0 1 2 4 -3 5 -4 -3 -2 -1 0 4 -1 0 1 2 8 1 0 -4 -1 0 -5 -3 -5 2 5 6 8 -4 -3 -2 -1 0 1 2 ...
output:
4 1999999988 0 5 1 5 11 0 10 0 0 0 0 11 0 0 0 1999999989 0 0 0 0 1999999981 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1999999997 0 0 0 0 0 3999999964 1999999974 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 1999999995 0 0 0 0 0 0 0 0 0 0 1999999990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong answer 6th numbers differ - expected: '1', found: '5'