50 10
95681386 13740267 8429097 39710681 88496164 38938674 97203902 38608716 89701274 14407932 7419
<448 bytes omitted>
用户输出
87405401
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#64344 | #1328. [L3-3]orzzxy | Accepted | 100 | 2007 ms | 20116 K | C++ 17 / 1.5 K | zxyoi | 2022-03-24 10:25:31 |
#include <bits/stdc++.h>
typedef long long ll;
namespace IO {
inline char gc() {
static const int Rlen = 1 << 22 | 1;
static char buf[Rlen], *p1, *p2;
return (p1 == p2) && (p2 = (p1 = buf) + fread(buf, 1, Rlen, stdin), p1 == p2) ? EOF : *p1++;
}
template <typename T>
T get_integer() {
bool f = false;
char c;
while (!isdigit(c = gc())) f = c == '-';
T x = c ^ 48;
while (isdigit(c = gc())) x = ((x + (x << 2)) << 1) + (c ^ 48);
return f ? -x : x;
}
inline int gi() { return get_integer<int>(); }
} // namespace IO
using namespace IO;
using std::cerr;
using std::cout;
const int N = 1e6 + 5;
int n, m, va, vb;
int a[N], b[N];
int l, r;
int lb[N], la[N];
inline bool check(int x) {
ll sum = 0, ans1 = 0, ans2 = 0;
for (int i = 1; i <= m; ++i) lb[i] = n;
for (int i = 1, j = m; i <= n; ++i) {
while (j && a[i] + b[j] > x) {
lb[j] = i - 1;
sum += n - lb[j];
--j;
}
la[i] = j;
}
for (int i = 0, j = 0; i <= n; ++i) {
sum += std::min(la[i], j) - m + std::max(la[i], j);
ans1 = std::max(ans1, sum);
ans2 = std::max(ans2, sum - (i < va && j < vb));
while (j < m && i >= n - lb[j + 1]) {
++j;
sum += i + lb[j] - n;
ans1 = std::max(ans1, sum);
ans2 = std::max(ans2, sum - (i < va && j < vb));
}
}
return ans1 == ans2;
}
void Main() {
n = gi(), m = gi();
for (int i = 1; i <= n; a[i++] = gi())
;
for (int j = 1; j <= m; b[j++] = gi())
;
va = a[1];
vb = b[1];
l = 2, r = va + vb;
std::sort(a + 1, a + n + 1);
va = std::lower_bound(a + 1, a + n + 1, va) - a;
std::sort(b + 1, b + m + 1);
vb = std::lower_bound(b + 1, b + m + 1, vb) - b;
while (l < r) {
int mid = (l + r) >> 1;
if (check(mid))
r = mid;
else
l = mid + 1;
}
std::cout << l << "\n";
}
void File() {
#ifdef zxyoi
#endif
}
signed main() {
File();
Main();
return 0;
}
50 10
95681386 13740267 8429097 39710681 88496164 38938674 97203902 38608716 89701274 14407932 7419
<448 bytes omitted>
用户输出
87405401
系统信息
Exited with return code 0
50 1
66856269 28042883 77526422 65997643 46475457 33984071 43927226 30328385 59703045 86992461 2310
<365 bytes omitted>
用户输出
108593483
系统信息
Exited with return code 0
50 50
974 433 886 465 3 253 944 2 536 810 907 820 59 987 66 957 107 475 459 971 672 35 442 842 17 9
<298 bytes omitted>
用户输出
1059
系统信息
Exited with return code 0
50 50
62304193 91247505 29251304 85213003 11694075 96199248 17711706 24586856 45656742 57554210 298
<795 bytes omitted>
用户输出
77919227
系统信息
Exited with return code 0
500 50
37471022 90908044 89290495 74090663 34176846 52896147 60807951 32127486 75091347 94370076 17
<4799 bytes omitted>
用户输出
103876206
系统信息
Exited with return code 0
500 100
77337258 9701595 57611984 10987592 12689202 16911119 59732809 53987239 26425454 35656764 66
<5252 bytes omitted>
用户输出
101500335
系统信息
Exited with return code 0
400 400
33626924 41214257 5976281 15928061 50647428 63388467 60395341 91930657 80991302 62944955 15
<7024 bytes omitted>
用户输出
77541656
系统信息
Exited with return code 0
500 500
4604524 93685669 45545752 11489330 22551534 36063327 11942182 75129852 80763562 8284144 298
<8778 bytes omitted>
用户输出
44617585
系统信息
Exited with return code 0
500 500
56336026 99452730 561207 31256111 8263826 90574159 10486182 12438862 28128603 75013994 9662
<8784 bytes omitted>
用户输出
97816312
系统信息
Exited with return code 0
500 500
10974956 71809100 4692096 44548438 86018853 17231834 69004155 71757771 22935819 82028309 63
<8815 bytes omitted>
用户输出
27980402
系统信息
Exited with return code 0
100000 1000
31471303 27788422 20214373 7813207 8412497 28735837 50145205 68447129 87207926 45800620
<897752 bytes omitted>
用户输出
85465897
系统信息
Exited with return code 0
100000 10000
90683794 96357195 40974857 96877233 68723911 64926906 15433702 94077241 69780221 21280
<977662 bytes omitted>
用户输出
99706142
系统信息
Exited with return code 0
100000 100000
58183970 10371460 83374966 6916961 4742174 4264899 95660692 89638641 57147154 437780
<1777948 bytes omitted>
用户输出
100222923
系统信息
Exited with return code 0
100000 100000
9 10 3 3 8 6 10 1 4 3 9 6 2 1 2 9 5 6 8 10 10 9 3 8 6 1 1 3 9 2 3 8 7 7 1 7 1 1 10 6
<419799 bytes omitted>
用户输出
11
系统信息
Exited with return code 0
100000 100000
54 96 89 8 99 58 98 23 76 89 30 78 74 44 98 63 71 80 43 92 49 61 67 35 88 87 3 9 50 4
<583960 bytes omitted>
用户输出
101
系统信息
Exited with return code 0
100000 100000
15680417 73720865 54261586 22261207 3624776 44961824 79725836 92933976 13306046 41731
<1777614 bytes omitted>
用户输出
38174840
系统信息
Exited with return code 0
1000000 1000000
354 601 43 767 767 88 251 738 461 921 719 29 807 349 748 234 779 679 448 882 598 15
<7786162 bytes omitted>
用户输出
1002
系统信息
Exited with return code 0
1000000 1000000
7424 6769 1055 5591 394 5341 15 9942 6840 7776 7139 2570 3389 1984 437 6022 9074 39
<9779082 bytes omitted>
用户输出
10003
系统信息
Exited with return code 0
1000000 1000000
47427 28679 25147 56901 20636 31712 73303 32054 11817 88114 16386 91137 75420 34153
<11777825 bytes omitted>
用户输出
99991
系统信息
Exited with return code 0