QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#178004 | #5378. 匹配问题 | zhoukangyang# | 0 | 1ms | 5876kb | C++11 | 1.3kb | 2023-09-13 17:11:10 | 2024-07-04 01:56:21 |
answer
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++)
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define ll long long
#define ull unsigned long long
#define sz(a) ((int) a.size())
#define vi vector<int>
#define me(a, x) memset(a, x, sizeof(a))
using namespace std;
const int N = 1 << 20, L = 5e5, mod = 998244353;
int n, la, lb;
int cnta[N], cntb[N];
int a[N], b[N];
multiset < int > st;
int main () {
ios :: sync_with_stdio(false);
cin.tie (0); cout.tie (0);
cin >> n >> la >> lb;
L(i, 1, n) {
cin >> a[i];
}
L(i, 1, n) {
cin >> b[i];
}
sort(a + 1, a + n + 1);
sort(b + 1, b + n + 1);
int pos = 1;
vi st;
int ans = 0;
L(i, 1, n) {
while(pos <= n && a[pos] <= b[i]) {
st.emplace_back(a[pos]);
++pos;
}
auto lw = lower_bound(st.begin(), st.end(), b[i] - lb);
int win = 0;
if(lw != st.end()) {
int val = *lw;
st.erase(lw);
win = 1;
if(la < L) {
L(j, 0, sz(st) - 1) {
if(st[j] + la < a[i + j + 1]) {
win = 0;
break;
}
}
}
if(!win) {
st.insert(lower_bound(st.begin(), st.end(), val), val);
} else {
++ans;
}
}
if(!win) {
st.erase(st.begin());
}
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 4
Accepted
time: 1ms
memory: 5876kb
input:
2 2 1 1 1 1 1
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5872kb
input:
10 200000 100000 34181 300096 24293 22680 402306 193269 438170 254676 188147 73971 216849 477743 461911 135785 467234 278230 287107 223666 124173 135091
output:
7
result:
ok single line: '7'
Test #3:
score: -4
Wrong Answer
time: 1ms
memory: 5668kb
input:
10 200000 50000 298370 136488 436143 52173 206095 140981 321188 407844 342157 193338 138374 383207 156748 442404 386749 492604 354156 229996 447123 418264
output:
7
result:
wrong answer 1st lines differ - expected: '5', found: '7'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #100:
score: 0
Time Limit Exceeded
input:
500000 500000 10 200184 74991 71203 334998 316800 34483 120570 301054 331108 232072 189788 397143 490296 56807 361700 88818 42376 460305 371750 450351 338384 429789 426045 445029 152316 408919 188124 144966 457495 475025 225370 260510 383159 495247 54319 246245 240728 372033 439599 119720 449020 451...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
0%