QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#317860 | #5378. 匹配问题 | yllcm | 0 | 0ms | 14032kb | C++14 | 1.5kb | 2024-01-29 20:44:37 | 2024-01-29 20:44:38 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define pii pair<int, int>
#define FR first
#define SE second
using namespace std;
inline int read() {
int x = 0; bool op = 0;
char c = getchar();
while(!isdigit(c))op |= (c == '-'), c = getchar();
while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
return op ? -x : x;
}
const int N = 1e6 + 10;
const int INF = 1e9;
int n, la, lb;
int a[N], b[N], cnt[N], mn[N], lim[N];
int main() {
n = read(); la = read(); lb = read();
for(int i = 1; i <= n; i++)a[i] = read();
for(int i = 1; i <= n; i++)b[i] = read(), cnt[b[i]]++;
for(int i = 1; i < N; i++)cnt[i] += cnt[i - 1];
sort(a + 1, a + 1 + n);
sort(b + 1, b + 1 + n);
for(int i = 1; i <= n; i++) {
int sum = 0; mn[i] = INF;
for(int j = 1; j <= i; j++) {
if(a[j] + la <= a[i] + lb) {
sum++;
mn[i] = min(mn[i], (cnt[a[i] + lb] - cnt[a[j] - 1]) - sum);
}
}
}
for(int i = 1; i <= n; i++)lim[i] = INF;
multiset<int> s;
int ans = 0;
for(int i = n, j = n; i; i--) {
while(b[j] >= a[i])s.insert(b[j--]);
for(int j = 1; j <= i; j++) {
if(a[j] + la > a[i] + lb) {
lim[j] = min(lim[j], mn[i]);
break;
}
}
int flg = 1;
for(int j = 1; j <= n; j++)if(!lim[j])flg = 0;
if(flg) {
auto it = s.upper_bound(a[i] + lb);
if(it != s.begin())ans++, s.erase(--it);
}
}
printf("%d\n", ans);
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: 0ms
memory: 14032kb
input:
2 2 1 1 1 1 1
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 12276kb
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: 0ms
memory: 12420kb
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:
6
result:
wrong answer 1st lines differ - expected: '5', found: '6'
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%