QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478111#8831. Chemistry Classmartinga#WA 7ms6264kbC++20957b2024-07-14 17:12:352024-07-14 17:12:35

Judging History

This is the latest submission verdict.

  • [2024-07-14 17:12:35]
  • Judged
  • Verdict: WA
  • Time: 7ms
  • Memory: 6264kb
  • [2024-07-14 17:12:35]
  • Submitted

answer

#include <bits/stdc++.h>
#define lli long long int
using namespace std;

void solveCase()
{
    int n, critical, acceptable;
    cin >> n >> critical >> acceptable;
    n <<= 1;
    vector<lli> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int solution = 0;
    for (int i = 0; i < n; i+=2)
    {
        int diff = v[i+1]-v[i];
        if (diff <= acceptable)
        {
            solution++;
        }
        else if (diff > critical)
        {
            cout << "-1\n"; return;
        }
        else
        {
            int beginning = v[i];
            while (i + 3 < n && v[i+3]-beginning <= critical && v[i+2] - v[i+1] <= acceptable)
            {
                i+=2; solution++;
            }
        }
    }
    cout << solution << "\n";
}

int main()
{
    int n; cin >> n; while (n--)
    {
        solveCase();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3800kb

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: 7ms
memory: 6264kb

input:

1
199996 67013419502794 1
403716252634677166 895717933735068492 410002430455111886 844431179242134559 322988383133810700 133475121268220299 481706326769800263 606871141911985391 195911124687409946 959578180866483093 930547702157856949 877914383714875160 994158366044742636 890855755285236186 69498488...

output:

199996

result:

wrong answer 1st numbers differ - expected: '0', found: '199996'