QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#527674 | #8831. Chemistry Class | StayAlone | WA | 128ms | 22336kb | C++14 | 2.1kb | 2024-08-22 18:10:24 | 2024-08-22 18:10:24 |
Judging History
answer
#include <bits/stdc++.h>
#define rep1(i, l, r) for (int i = l; i <= int(r); ++i)
#define rep2(i, l, r) for (int i = l; i >= int(r); --i)
#define rer(i, l, r, a) rep1(i, l, r) read(a[i])
#define ptc putchar
#define il inline
#define eb emplace_back
#define ef emplace_front
#define mp make_pair
#define fst first
#define snd second
#define sqr(x) ((x) * (x))
#define ls(x) x << 1
#define rs(x) x << 1 | 1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef __int128 bll;
// typedef unsigned __int128 ubll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e5 + 10;
const int LOGN = log2(MAXN) + 1, inf = ~0U >> 2, INF = ~0U >> 1;
const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
namespace stupid_lrc {
template <typename T> il bool read(T &x) {
x = 0; bool f = false; char ch;
while (!isdigit(ch = getchar())) {
f ^= !(ch ^ '-');
if (ch == EOF) return false;
}
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch & 15), ch = getchar();
if (f) x = ~x + 1; return true;
}
il ll read() {ll x; read(x); return x;}
template <typename T> il bool read(pair <T, T> &x) {return read(x.fst) && read(x.snd);}
template <typename T> il void gmin(T &x, T y) {x = x < y ? x : y;}
template <typename T> il void gmax(T &x, T y) {x = x > y ? x : y;}
template <typename T, typename ...L>
il bool read(T &x, L &...y) {return read(x) && read(y...);}
template <typename T> il T lowbit(const T &x) {return x & -x;}
}
using namespace stupid_lrc;
int n; ll a, b;
multiset <ll> now;
il void solve() {
read(n, a, b); now.clear();
int ans = 0;
rep1(i, 1, n << 1) now.emplace(read());
while (now.size()) {
ll p = *now.begin(); now.erase(now.begin());
// cout << "!!" << p << endl;
auto it = now.upper_bound(p + b);
if (it != now.begin()) ++ans, now.erase(--it);
else {
auto it = now.upper_bound(p + a);
if (it == now.begin()) return puts("-1"), void();
else now.erase(--it);
}
} printf("%d\n", ans);
}
int main() {
for (int T = read(); T--; ) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
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: 128ms
memory: 22336kb
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'