QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#457918 | #8831. Chemistry Class | ucup-team1525# | WA | 49ms | 6972kb | C++20 | 1.3kb | 2024-06-29 14:47:07 | 2024-06-29 14:47:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
#define ll long long
int n,t;
ll A,B;
ll a[2*N];
ll st[10];
int top;
int main()
{
scanf("%d",&t);
while (t--)
{
scanf("%d%lld%lld",&n,&A,&B);
for (int i=1;i<=n*2;++i)
scanf("%lld",&a[i]);
sort(a+1,a+1+n);
bool b=true;
for (int i=1;i<=n*2;i+=2)
if (a[i+1]-a[i]>A)
{
b=false;
break;
}
if (!b)
{
puts("-1");
continue;
}
int ans=0;
top=0;
for (int i=1;i<=n*2;++i)
{
if (top==2)
{
if (a[i]-st[top]<=B)
{
if (a[i+1]-st[1]<=A)
{
++ans;
--top;
continue;
}
}
else
top=0;
}
if (top==1)
{
if (a[i]-st[top]<=B)
{
++ans;
--top;
continue;
}
}
st[++top]=a[i];
}
printf("%d\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
input:
4 1 2 1 42 69 2 3 1 1 2 3 4 2 5 1 6 1 3 4 5 19 1 1 7 8 9 10 11 12 13 14 20
output:
-1 2 1 4
result:
ok 4 number(s): "-1 2 1 4"
Test #2:
score: -100
Wrong Answer
time: 49ms
memory: 6972kb
input:
1 199996 67013419502794 1 403716252634677166 895717933735068492 410002430455111886 844431179242134559 322988383133810700 133475121268220299 481706326769800263 606871141911985391 195911124687409946 959578180866483093 930547702157856949 877914383714875160 994158366044742636 890855755285236186 69498488...
output:
-1
result:
wrong answer 1st numbers differ - expected: '0', found: '-1'