QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#551797#8831. Chemistry ClassAA_Surely#WA 1ms5660kbC++231.1kb2024-09-07 18:09:282024-09-07 18:09:29

Judging History

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

  • [2024-09-07 18:09:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5660kb
  • [2024-09-07 18:09:28]
  • 提交

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;

int n;
LL 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);
    fill(dp, dp + n + 1, 0);

    for(int i = 1; i < n; i += 2) {
        if (ns[i] - ns[i - 1] > a) {
            cout << -1 << endl;
            return;
        }
        if (ns[i] - ns[i - 1] <= b) dp[i] = max(dp[i], (i >= 2 ? dp[i - 2] + 1 : 1));
        if (i >= 2) dp[i] = max(dp[i - 2], dp[i]);
        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: 0
Wrong Answer
time: 1ms
memory: 5660kb

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
3

result:

wrong answer 4th numbers differ - expected: '4', found: '3'