QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551791#8831. Chemistry ClassAA_Surely#WA 3ms9100kbC++231.1kb2024-09-07 18:07:172024-09-07 18:07:17

Judging History

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

  • [2024-09-07 18:07:17]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:9100kb
  • [2024-09-07 18:07:17]
  • 提交

answer

#include <bits/stdc++.h>

#define FOR(i, x, n) for(int i = x; i < n; i++)
#define F0R(i, n) FOR(i, 0, n)

#define F first
#define S second
#define PB push_back

#define WTF cout << "WTF" << endl;

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);

using namespace std;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;

const int N = 1e6 + 7;
const int INF = 1e9 + 7;
const int MOD = 998'244'353;

int n;
int ns[N], dp[N];
LL a, b;

void solve() {
    cin >> n >> a >> b;
    n *= 2;
    F0R(i, n) cin >> ns[i];
    sort(ns, ns + n);

    int ans = 0;
    for(int i = 1; i < n; i += 2) {
        if (ns[i] - ns[i - 1] <= b) dp[i] = (i >= 2 ? dp[i - 2] + 1 : 1);
        else if (ns[i] - ns[i - 1] > a) {
            cout << -1 << endl;
            return;
        }
        else {
            if (i >= 2) dp[i] = dp[i - 2];
            if (i >= 3 && ns[i] - ns[i - 3] <= a && ns[i - 1] - ns[i - 2] <= b) 
                dp[i] = max(dp[i], (i >= 4 ? dp[i - 4] : 0) + 1);
        }
    }

    cout << dp[n - 1] << endl;
}

int main() {
    IOS;
    int t; cin >> t;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

199995

result:

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