QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#718885 | #9609. 幽默还是夢 | zlt | 100 ✓ | 1357ms | 92468kb | C++14 | 10.3kb | 2024-11-06 21:41:02 | 2024-11-06 21:41:09 |
Judging History
answer
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define uint unsigned
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
namespace IO {
const int maxn = 1 << 20;
char ibuf[maxn], *iS, *iT, obuf[maxn], *oS = obuf;
inline char gc() {
return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin), (iS == iT ? EOF : *iS++) : *iS++);
}
template<typename T = int>
inline T read() {
char c = gc();
T x = 0;
bool f = 0;
while (c < '0' || c > '9') {
f |= (c == '-');
c = gc();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ 48);
c = gc();
}
return f ? ~(x - 1) : x;
}
inline void flush() {
fwrite(obuf, 1, oS - obuf, stdout);
oS = obuf;
}
struct Flusher {
~Flusher() {
flush();
}
} AutoFlush;
inline void pc(char ch) {
if (oS == obuf + maxn) {
flush();
}
*oS++ = ch;
}
template<typename T>
inline void write(T x) {
static char stk[64], *tp = stk;
if (x < 0) {
x = ~(x - 1);
pc('-');
}
do {
*tp++ = x % 10;
x /= 10;
} while (x);
while (tp != stk) {
pc((*--tp) | 48);
}
}
template<typename T>
inline void writesp(T x) {
write(x);
pc(' ');
}
template<typename T>
inline void writeln(T x) {
write(x);
pc('\n');
}
}
using IO::read;
using IO::write;
using IO::pc;
using IO::writesp;
using IO::writeln;
const int maxn = 400100;
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
ll n, m, nt, N;
pii c[maxn];
bool vis[maxn];
struct item {
ll x, o, i, y;
item(ll a = 0, ll b = 0, ll c = 0, ll d = 0) : x(a), o(b), i(c), y(d) {}
} a[maxn];
inline bool operator < (const item &a, const item &b) {
if (a.x * b.o != b.x * a.o) {
return a.x * b.o < b.x * a.o;
} else {
return a.i < b.i;
}
}
struct node {
ll a, b, x, y;
} b[maxn];
struct que {
ll o, x, y, z, xx, yy, mx1, mx2, mn, cnt, sum, ans;
} qq[maxn];
inline int ID(item x) {
// printf("ID %lld %lld %lld %lld %lld\n", x.x, x.o, x.i, x.y, (ll)(lower_bound(a + 1, a + nt + 1, x) - a));
return lower_bound(a + 1, a + nt + 1, x) - a;
}
struct event {
int o, i, x;
event(int a = 0, int b = 0, int c = 0) : o(a), i(b), x(c) {}
};
struct BIT {
ll a[maxn], b[maxn];
inline void update(ll x, ll y, ll z) {
for (int i = x; i <= n; i += (i & (-i))) {
a[i] += y;
b[i] += z;
}
}
inline void clear(ll x) {
for (int i = x; i <= n; i += (i & (-i))) {
a[i] = b[i] = 0;
}
}
inline pii query(ll x) {
ll s1 = 0, s2 = 0;
for (int i = x; i; i -= (i & (-i))) {
s1 += a[i];
s2 += b[i];
}
return mkp(s1, s2);
}
inline pii query(ll l, ll r) {
pii p = query(l - 1), q = query(r);
return mkp(q.fst - p.fst, q.scd - p.scd);
}
} T1;
struct Heap {
vector<ll> a;
inline void clear() {
a.clear();
}
inline void insert(ll x) {
// printf("insert %lld\n", x);
a.insert(lower_bound(a.begin(), a.end(), x), x);
}
inline void erase(ll x) {
// printf("erase %lld\n", x);
assert(find(a.begin(), a.end(), x) != a.end());
a.erase(lower_bound(a.begin(), a.end(), x));
}
inline ll qmx() {
return a.size() ? a.back() : -inf;
}
inline ll qmn() {
return a.size() ? a[0] : inf;
}
} S1[maxn >> 2], S2[maxn >> 2], S3[maxn >> 2];
struct wwh {
ll mx1, mx2;
wwh(ll a = 0, ll b = 0) : mx1(a), mx2(b) {}
};
inline wwh operator + (const wwh &a, const wwh &b) {
return wwh(max(a.mx1, b.mx1), max(a.mx2, b.mx2));
}
struct SGT1 {
wwh a[maxn];
inline void init() {
for (int i = 0; i < maxn; ++i) {
a[i] = wwh(-inf, -inf);
}
}
inline void update(int x, wwh y) {
x += N;
a[x] = y;
x >>= 1;
while (x) {
a[x] = a[x << 1] + a[x << 1 | 1];
x >>= 1;
}
}
inline void query(int l, int r, wwh &x) {
for (l += N - 1, r += N + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
if (!(l & 1)) {
x = x + a[l ^ 1];
}
if (r & 1) {
x = x + a[r ^ 1];
}
}
}
} T2;
struct SGT2 {
ll a[maxn];
inline void init() {
mems(a, 0x3f);
}
inline void update(int x, ll y) {
x += N;
a[x] = y;
x >>= 1;
while (x) {
a[x] = min(a[x << 1], a[x << 1 | 1]);
x >>= 1;
}
}
inline ll query(int l, int r) {
ll res = inf;
for (l += N - 1, r += N + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
if (!(l & 1)) {
res = min(res, a[l ^ 1]);
}
if (r & 1) {
res = min(res, a[r ^ 1]);
}
}
return res;
}
} T3;
void dfs(int l, int r, vector<event> Q) {
if (Q.empty()) {
return;
}
// printf("%d %d %d\n", l, r, (int)Q.size());
if (l == r) {
for (event e : Q) {
int o = e.o, i = e.i, x = e.x;
if (o == 1) {
T1.update(x, a[i].o, a[i].x);
if (a[i].o == 1) {
S2[x].insert(a[i].x);
} else {
S1[x].insert(a[i].x);
S2[x].insert(a[i].x - a[i].y);
}
T2.update(x, wwh(S1[x].qmx(), S2[x].qmx()));
} else if (o == -1) {
T1.update(x, -a[i].o, -a[i].x);
if (a[i].o == 1) {
S2[x].erase(a[i].x);
} else {
S1[x].erase(a[i].x);
S2[x].erase(a[i].x - a[i].y);
}
T2.update(x, wwh(S1[x].qmx(), S2[x].qmx()));
} else {
pii p = T1.query(qq[i].x, qq[i].y);
wwh t(-inf, -inf);
T2.query(qq[i].x, qq[i].y, t);
qq[i].mx1 = max(qq[i].mx1, t.mx1);
qq[i].mx2 = max(qq[i].mx2, t.mx2);
qq[i].cnt += p.fst;
qq[i].sum += p.scd;
// if (i == 1) {
// printf("%lld %lld\n", qq[i].cnt, qq[i].sum);
// }
if (qq[i].cnt == qq[i].z) {
qq[i].ans = qq[i].sum;
} else {
qq[i].ans = qq[i].sum + min(qq[i].mn - qq[i].mx1, -qq[i].mx2);
}
}
}
for (event e : Q) {
int o = e.o, x = e.x;
if (o == 1) {
T1.clear(x);
S1[x].clear();
S2[x].clear();
T2.update(x, wwh(-inf, -inf));
}
}
return;
}
// printf("l, r: %d %d\n", l, r);
int mid = (l + r) >> 1;
vector<event> L, R;
for (event e : Q) {
int o = e.o, i = e.i, x = e.x;
if (o == 1) {
if (i <= mid) {
// printf("update %d %lld %lld\n", x, a[i].o, a[i].x);
T1.update(x, a[i].o, a[i].x);
L.pb(e);
} else {
R.pb(e);
}
} else if (o == -1) {
if (i <= mid) {
T1.update(x, -a[i].o, -a[i].x);
L.pb(e);
} else {
R.pb(e);
}
} else {
pii p = T1.query(qq[i].x, qq[i].y);
// if (i == 1) {
// printf("%lld %lld %lld %lld\n", p.fst, p.scd, qq[i].cnt, qq[i].sum);
// }
if (p.fst >= qq[i].z - qq[i].cnt) {
vis[i] = 1;
L.pb(e);
} else {
qq[i].cnt += p.fst;
qq[i].sum += p.scd;
vis[i] = 0;
R.pb(e);
}
}
}
for (event e : Q) {
int o = e.o, i = e.i, x = e.x;
// printf("o: %d, i: %d, x: %d\n", o, i, x);
if (o == 1) {
if (i <= mid) {
T1.clear(x);
if (a[i].o == 1) {
S2[x].insert(a[i].x);
} else {
S1[x].insert(a[i].x);
S2[x].insert(a[i].x - a[i].y);
}
T2.update(x, wwh(S1[x].qmx(), S2[x].qmx()));
} else {
if (a[i].o == 1) {
S3[x].insert(a[i].x);
} else {
S3[x].insert(a[i].y);
}
T3.update(x, S3[x].qmn());
}
} else if (o == -1) {
if (i <= mid) {
if (a[i].o == 1) {
// printf("x: %lld\n", a[i].x);
S2[x].erase(a[i].x);
} else {
// printf("i: %d\n", i);
// printf("x, y: %lld %lld\n", a[i].x, a[i].y);
S1[x].erase(a[i].x);
S2[x].erase(a[i].x - a[i].y);
}
T2.update(x, wwh(S1[x].qmx(), S2[x].qmx()));
} else {
if (a[i].o == 1) {
S3[x].erase(a[i].x);
} else {
S3[x].erase(a[i].y);
}
T3.update(x, S3[x].qmn());
}
} else if (vis[i]) {
// puts("here1");
qq[i].mn = min(qq[i].mn, T3.query(qq[i].x, qq[i].y));
} else {
// puts("here2");
wwh t(-inf, -inf);
T2.query(qq[i].x, qq[i].y, t);
qq[i].mx1 = max(qq[i].mx1, t.mx1);
qq[i].mx2 = max(qq[i].mx2, t.mx2);
}
}
for (event e : Q) {
int o = e.o, i = e.i, x = e.x;
if (o == 1) {
if (i <= mid) {
S1[x].clear();
S2[x].clear();
T2.update(x, wwh(-inf, -inf));
} else {
S3[x].clear();
T3.update(x, inf);
}
}
}
dfs(l, mid, L);
dfs(mid + 1, r, R);
}
void solve() {
n = read();
m = read();
N = 1;
while (N < n + 2) {
N <<= 1;
}
for (int i = 1; i <= n; ++i) {
b[i].a = read();
b[i].b = read();
if (b[i].a * 2 <= b[i].b) {
b[i].x = ++nt;
a[nt] = item(b[i].a, 1, nt);
b[i].y = ++nt;
a[nt] = item(b[i].b - b[i].a, 1, nt);
} else {
b[i].x = ++nt;
a[nt] = item(b[i].b, 2, nt, b[i].a);
}
}
for (int i = 1; i <= m; ++i) {
qq[i].o = read();
qq[i].x = read();
qq[i].y = read();
qq[i].z = read();
if (qq[i].o == 1) {
++qq[i].x;
if (qq[i].y * 2 <= qq[i].z) {
qq[i].xx = ++nt;
a[nt] = item(qq[i].y, 1, nt);
qq[i].yy = ++nt;
a[nt] = item(qq[i].z - qq[i].y, 1, nt);
} else {
qq[i].xx = ++nt;
a[nt] = item(qq[i].z, 2, nt, qq[i].y);
}
} else {
++qq[i].x;
++qq[i].y;
qq[i].mx1 = qq[i].mx2 = -inf;
qq[i].mn = inf;
}
}
sort(a + 1, a + nt + 1);
vector<event> Q;
for (int i = 1; i <= n; ++i) {
if (b[i].a * 2 <= b[i].b) {
b[i].x = ID(item(b[i].a, 1, b[i].x));
b[i].y = ID(item(b[i].b - b[i].a, 1, b[i].y));
c[i] = mkp(b[i].x, b[i].y);
Q.pb(1, b[i].x, i);
Q.pb(1, b[i].y, i);
} else {
b[i].x = ID(item(b[i].b, 2, b[i].x, b[i].a));
c[i] = mkp(b[i].x, 0);
Q.pb(1, b[i].x, i);
}
}
for (int i = 1; i <= m; ++i) {
if (qq[i].o == 1) {
Q.pb(-1, c[qq[i].x].fst, qq[i].x);
if (c[qq[i].x].scd) {
Q.pb(-1, c[qq[i].x].scd, qq[i].x);
}
if (qq[i].y * 2 <= qq[i].z) {
qq[i].xx = ID(item(qq[i].y, 1, qq[i].xx));
qq[i].yy = ID(item(qq[i].z - qq[i].y, 1, qq[i].yy));
Q.pb(1, qq[i].xx, qq[i].x);
Q.pb(1, qq[i].yy, qq[i].x);
c[qq[i].x] = mkp(qq[i].xx, qq[i].yy);
} else {
qq[i].xx = ID(item(qq[i].z, 2, qq[i].xx, qq[i].y));
Q.pb(1, qq[i].xx, qq[i].x);
c[qq[i].x] = mkp(qq[i].xx, 0);
}
} else {
Q.pb(0, i, 0);
}
}
T2.init();
T3.init();
dfs(1, nt, Q);
for (int i = 1; i <= m; ++i) {
if (qq[i].o == 2) {
writeln(qq[i].ans);
}
}
}
int main() {
int T = 1;
// scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 8ms
memory: 43052kb
input:
3 5 3 6 2 7 3 6 1 1 1 6 1 0 2 3 1 1 4 9 2 0 1 4 2 0 2 4
output:
12 9
result:
ok 2 number(s): "12 9"
Test #2:
score: 5
Accepted
time: 0ms
memory: 44264kb
input:
3 5 5 6 5 6 5 10 2 1 2 1 1 2 5 9 1 1 1 2 2 0 1 3 1 0 4 8
output:
5 7
result:
ok 2 number(s): "5 7"
Test #3:
score: 5
Accepted
time: 0ms
memory: 44056kb
input:
5 3 1 6 4 5 1 3 4 6 4 7 2 0 1 2 2 3 3 1 2 0 4 6
output:
5 4 13
result:
ok 3 number(s): "5 4 13"
Test #4:
score: 5
Accepted
time: 0ms
memory: 44596kb
input:
14 14 137604651 148051578 362722420 701127241 112668315 125437888 287900155 387914570 372764764 835453510 487901436 886003378 220152717 420521021 398973222 512891403 388384759 595247888 89781009 585869215 26792323 118929846 336453982 364990768 321824819 613043271 388186725 818512652 1 6 181262309 25...
output:
1361305890 625931363 196861445 1202933382 575465932 450028044 456536086 253166599 1485150610 196861445 748691543
result:
ok 11 numbers
Test #5:
score: 5
Accepted
time: 5ms
memory: 44044kb
input:
14 14 6 20 5 8 6 22 6 20 20 31 18 35 16 22 7 25 15 21 2 3 2 18 5 22 20 27 5 8 2 3 9 12 2 4 8 7 2 0 7 4 2 0 1 3 1 11 1 18 2 8 10 4 2 1 5 9 1 6 10 16 1 5 12 19 2 6 8 4 1 2 8 27 2 1 11 14 2 2 12 5 2 7 9 6
output:
122 81 20 14 20 99 37 83 12 49
result:
ok 10 numbers
Test #6:
score: 5
Accepted
time: 0ms
memory: 43828kb
input:
14 14 3 22 7 15 11 12 16 29 17 36 9 22 11 14 15 19 7 24 20 30 2 7 14 17 1 8 15 24 2 6 12 2 1 8 13 24 1 6 11 18 1 1 8 24 1 3 14 29 1 5 17 33 1 5 3 14 1 1 7 15 2 0 11 18 1 10 14 22 1 2 15 28 2 4 4 1 2 9 13 1 1 6 14 27
output:
3 143 17 1
result:
ok 4 number(s): "3 143 17 1"
Test #7:
score: 5
Accepted
time: 6ms
memory: 44080kb
input:
14 14 257829907 724715537 108651452 258598766 94683229 173211791 479210658 582119116 54540156 428302979 52455936 383613089 490920498 513399791 352653592 701946471 340154330 398349800 121686359 192733077 88773311 129421949 320698287 575819706 170879293 344150256 302356504 521941463 2 3 12 10 1 8 2452...
output:
1171651174 429151118 2188227897 575819706 284981414 1615206255 320698287 1593325327 129421949
result:
ok 9 numbers
Subtask #2:
score: 5
Accepted
Dependency #1:
100%
Accepted
Test #8:
score: 5
Accepted
time: 5ms
memory: 42808kb
input:
300 300 236272593 367977426 193245445 202346765 154060783 238627896 266263504 714515068 326570377 765576129 319118394 352576872 105744828 271847570 1123063 437252936 292326814 652693639 119178460 320083080 392059409 484903780 178885480 591157929 273931331 692199866 156093219 524526946 323752415 8226...
output:
12903467467 12140459036 15087634605 27198807498 29428660401 6169823972 15045538543 4383591 2359669927 1063857724 694501138 24620774975 9566547346 65353375060 10241685703 121125504 13264370395 9581854028 14132735946 77877326550 285563821 9085006335 18424522279 7729941213 6497908382 28538021992 662892...
result:
ok 146 numbers
Test #9:
score: 5
Accepted
time: 3ms
memory: 43640kb
input:
300 300 244663179 509035792 332903389 613341357 161987994 606940171 336723050 507606507 145455363 204317531 169573385 379283435 177050397 562868538 431733852 523770709 212243619 281715538 83255800 160178888 294475851 697375668 343483612 775166562 281248069 495482283 138995617 554668578 194259365 216...
output:
40254603 16369627943 2448905059 1868439239 1057562633 7471849467 14589706661 50073674230 3644726912 63713269 13049201228 16762172359 17712958839 18411593284 8546622062 33190286201 18793253982 10814998349 5882894800 15312531098 52138307 13762650523 1488748067 22823558723 11962399128 41833685078 40483...
result:
ok 143 numbers
Test #10:
score: 5
Accepted
time: 7ms
memory: 43704kb
input:
300 300 72911832 469485383 105942845 273018682 232457225 578806174 269721902 378206843 103384491 595940124 364126138 549620383 468136415 829403771 79997976 363085297 320307362 535761950 395259575 761297849 241479722 357024290 411307155 562957441 288347269 448717572 256345663 393867710 363610578 4187...
output:
6913154278 2842330034 2185597552 32914182697 3349781269 33240231006 13292793883 35013050874 36781788100 4492425969 733292842 2680419448 28899224522 178152769 3612931177 15062161441 4227210687 2083096048 62437668974 9145335161 20152648 1755242090 462627834 3738164822 3792823081 59119687341 1413096882...
result:
ok 170 numbers
Test #11:
score: 5
Accepted
time: 10ms
memory: 42956kb
input:
300 300 17 28 7 19 17 19 8 12 2 10 15 22 5 19 19 31 8 25 19 22 6 12 1 12 16 22 4 5 10 27 10 12 16 23 16 35 5 12 4 16 12 27 8 16 17 19 10 24 10 26 16 18 13 14 12 17 7 24 14 29 11 23 14 33 8 24 5 21 2 16 2 17 19 26 2 17 14 16 11 17 7 17 3 10 4 11 14 34 11 13 12 24 15 27 10 25 19 23 2 22 5 11 12 32 3 1...
output:
3276 1662 1369 243 286 290 3411 346 1563 88 787 441 295 223 2238 2632 1012 126 1129 10 621 30 237 1111 1117 596 555 152 251 444 659 207 712 1934 82 112 320 222 1136 1417 598 19 114 1414 576 201 1815 4037 1034 373 515 428 65 181 84 135 285 1 89 258 2 160 236 794 249 61 1770 21 430 103 48 44 405 113 1...
result:
ok 140 numbers
Test #12:
score: 5
Accepted
time: 0ms
memory: 42688kb
input:
300 300 17 29 20 26 2 22 3 11 19 37 7 26 14 23 3 16 7 10 13 20 5 19 14 24 2 4 1 8 19 36 11 30 1 2 20 29 13 28 12 24 18 34 13 23 20 26 20 36 11 22 11 31 13 14 20 34 2 4 11 14 5 22 13 23 12 13 7 23 7 23 15 26 20 29 2 12 6 11 19 25 9 13 5 10 16 20 17 30 7 11 18 25 11 14 6 26 2 16 1 2 18 30 10 18 10 16 ...
output:
203 455 2 3824 2036 7 217 2680 502 3 27 496 78 544 1126 61 1058 311 1797 1218 164 3114 50 1536 130 3433 5 2451 83 2132 216 710 449 3189 255 1108 1088 498 163 1647 179 516 2 262 2605 160 459 293 481 211 1963 441 404 330 126 45 697 64 36 892 393 56 117 3593 726 3051 654 5 1063 1922 1263 956 200 259 12...
result:
ok 142 numbers
Subtask #3:
score: 15
Accepted
Dependency #2:
100%
Accepted
Test #13:
score: 15
Accepted
time: 11ms
memory: 42168kb
input:
2000 2000 492156297 891105567 457854002 671145682 119875716 213459413 129540041 445263628 45723424 297701781 243530727 413420086 343868745 465766786 39585054 342872573 245699946 297595828 283288483 332910548 19248601 74422280 305868175 725593305 137155918 635077642 186537009 320193545 449764641 9168...
output:
769333315 31814430233 192156363 10731582114 310909096915 205483963778 124233092017 268012585576 164616784041 38053660249 9480536842 158352240104 407150954886 17063476029 82258316259 21369738423 3266683042 272282626186 556810418612 75466361119 398580395 186178907785 564338317766 145374417881 27185904...
result:
ok 965 numbers
Test #14:
score: 15
Accepted
time: 12ms
memory: 45628kb
input:
2000 2000 199918641 456527544 260775423 495168036 454126239 624980472 25503786 95958076 23049625 205204895 398321843 644801632 23803572 367932566 63791123 443652304 16717424 461899786 57182702 134288560 7367915 413777915 461864555 750003900 221881777 613181615 121094 462492090 235789679 722704353 13...
output:
119394915468 17941562480 279125740743 2233864829 106860370137 54758865798 143679361393 1877398337 779567529317 40363989047 263489643774 55000571549 7132978602 18526821294 222577978228 15638261704 161092153447 156826695129 36606198617 220813405946 60955688238 275212249345 221129445815 59748325945 163...
result:
ok 969 numbers
Test #15:
score: 15
Accepted
time: 12ms
memory: 45456kb
input:
2000 2000 497204382 995759939 221489796 251373672 498330228 556418029 450120891 715563300 307205005 406128293 215762347 678991374 86646319 139613276 8016302 35662129 25286265 324810382 371712021 641916776 63661846 497446528 458951932 868655385 10641798 205365852 319615379 615786917 90106107 41041485...
output:
13741251535 23390871836 13803366145 6846598624 164727658887 161453438707 151504751806 4382792638 1888841444 43321838168 118063814074 62184098093 132756597809 7616990021 65196341872 104234091197 148562690039 161010686208 108370261703 185354238433 202041650695 205544165494 65269540158 14074240805 5254...
result:
ok 991 numbers
Test #16:
score: 15
Accepted
time: 11ms
memory: 43848kb
input:
2000 2000 10 11 16 34 10 16 9 29 19 39 4 22 3 14 5 25 3 5 17 18 13 20 12 13 1 10 18 38 6 21 13 30 18 38 2 8 12 23 8 15 11 14 4 7 5 20 7 21 9 11 18 27 8 17 13 20 5 23 9 20 1 10 13 18 14 24 6 12 7 9 18 20 11 13 16 25 3 4 9 11 16 17 11 19 3 8 16 28 18 30 11 14 15 16 9 20 14 33 15 28 9 15 9 25 2 10 4 12...
output:
5957 212 178 14513 20720 130 2831 16927 528 12 3885 370 6136 612 251 9095 1576 938 1366 6681 9451 2684 1642 13112 15777 1709 183 5155 8464 689 3061 751 20692 1057 11712 1108 8393 26590 18884 700 6835 19272 3232 2930 5193 14623 1671 131 265 9420 608 10727 4979 3214 133 3276 79 7704 1353 14491 636 31 ...
result:
ok 1000 numbers
Test #17:
score: 15
Accepted
time: 11ms
memory: 42800kb
input:
2000 2000 2 21 2 13 20 30 12 16 20 35 11 29 14 24 18 24 20 40 17 36 18 24 5 14 1 4 17 32 14 17 9 28 17 23 18 34 12 15 2 6 15 25 17 26 16 34 8 14 3 7 10 16 9 18 19 37 10 23 8 21 3 7 18 30 11 22 11 13 18 22 7 9 14 19 17 26 9 19 7 24 7 21 10 22 7 24 19 22 13 27 5 13 16 31 20 23 6 19 4 10 5 23 8 15 16 2...
output:
2255 1934 415 3781 33403 12881 4926 2129 20 420 9383 18403 6987 432 136 17871 692 4679 210 14670 1077 239 123 4675 7014 507 9103 751 15 168 26078 1139 25299 8914 6065 199 11315 7903 17344 4695 2851 9185 1045 870 2899 15438 2382 30 1680 40 8854 7996 2726 21484 4416 4461 1167 202 7877 169 7871 281 134...
result:
ok 989 numbers
Subtask #4:
score: 15
Accepted
Test #18:
score: 15
Accepted
time: 629ms
memory: 82840kb
input:
100000 100000 14 26 20 23 12 27 12 26 19 31 19 36 19 31 4 20 6 10 10 20 3 6 5 8 12 23 2 14 11 15 7 12 4 8 3 11 17 32 5 21 20 37 14 23 11 15 1 8 10 18 9 26 15 34 14 20 4 19 1 20 13 18 1 5 9 21 3 6 12 18 18 24 2 12 10 22 7 21 4 7 13 20 11 23 19 37 5 18 15 18 12 26 8 10 7 23 7 26 17 23 4 15 15 22 2 10 ...
output:
244286 495160 8247 184124 1081788 419142 95206 1074493 603943 1638712 653728 1017818 24131 15831 282153 89716 986728 194180 22867 213733 1690294 477881 968078 453993 87723 32753 208011 232700 137866 1005953 965579 123747 29951 341394 18688 553772 191767 37015 503268 205384 247728 13492 13721 1170102...
result:
ok 100000 numbers
Test #19:
score: 15
Accepted
time: 740ms
memory: 83236kb
input:
100000 100000 20 29 5 15 16 25 1 21 19 34 7 10 12 13 14 30 12 30 8 13 1 7 3 10 1 14 4 10 10 28 20 37 7 14 14 29 6 19 17 21 10 22 3 17 3 6 10 24 3 22 1 13 3 19 7 12 20 29 6 25 2 7 10 12 18 19 16 22 1 8 1 3 20 40 1 5 10 22 1 2 16 21 5 24 5 13 20 33 16 35 1 5 14 28 16 20 4 23 15 20 20 36 9 14 10 23 2 8...
output:
595610 119081 788293 595760 712964 803612 3921 65202 307181 240737 12363 520827 836789 620970 1205878 62573 8427 742084 4535 14046 832624 179398 1125668 113778 6892 702854 32648 206252 320932 729046 178198 407453 471087 63814 1318958 914103 156849 103017 815266 195157 139885 259083 875402 1140884 13...
result:
ok 100000 numbers
Test #20:
score: 15
Accepted
time: 829ms
memory: 80072kb
input:
100000 100000 495149378 762667561 92804801 308704323 260829713 509258393 134985566 187603067 383688858 757703758 42584446 252140878 166171841 311884216 58894085 484698822 179904149 225131551 106046268 116048600 328369376 585575759 218728521 630432352 68063601 359383282 460115977 601281324 220720076 ...
output:
1812758092870 716777280196 6762481378372 5393411023109 20387004166659 276374836225 14393163199104 9060733840 708586821641 4402046274097 2995328388042 2426475426800 21365055698803 11654990261354 51051781302 807378906271 208257912510 14473781318613 2205074631517 2421075838275 1065039429683 16657175932...
result:
ok 100000 numbers
Test #21:
score: 15
Accepted
time: 797ms
memory: 81036kb
input:
100000 100000 317671798 724513306 267415730 720622263 438259841 609710587 338546641 679403828 414231034 428534303 72643161 493536554 351537022 385752969 99714633 133544561 22698327 381893760 176354095 231931408 489389965 775484006 264484999 269535193 240651757 350055491 3198275 407316049 308982646 5...
output:
239664815650 928888656042 2522829786033 43421209836739 5936815154306 12853457653071 1732783572874 8251302341580 709067422607 238590288446 40977678771 10727804866349 7476507892776 29223998617343 771404401863 25709809527597 189506325987 1482915516071 5309113956440 9169425573176 3902737030445 710730162...
result:
ok 100000 numbers
Test #22:
score: 15
Accepted
time: 849ms
memory: 80992kb
input:
100000 100000 350918315 359860548 469242404 928286463 199848321 507144420 266406590 637249851 92353752 538740822 355402324 492949190 77210679 423543086 60409773 435780188 12858185 328118533 436007287 856917524 233221654 545374045 4445595 334802817 14919077 428793589 285244243 337211810 48048546 4072...
output:
8051083624579 23566016619108 2179111806525 5316969302824 17783792865680 14832397287 3427227827375 5749419168056 25052813811875 9471567687067 15120661365228 13742344324346 409345333144 2222638824482 87246968549 31257792038098 12310709907568 4140428882471 9136752968253 2947148850202 29726531818326 168...
result:
ok 100000 numbers
Subtask #5:
score: 20
Accepted
Dependency #4:
100%
Accepted
Test #23:
score: 20
Accepted
time: 808ms
memory: 82504kb
input:
100000 100000 42072021 321809124 39872170 528597932 168585925 552562119 52246248 109524671 14770770 394983740 394986440 760758372 200610206 337295324 236903605 385901832 378712853 392866698 194639543 301474849 152944705 382720993 444881957 449478597 91981395 249429741 46866736 92449084 170002170 609...
output:
12256131816619 5168598209746 831671432639 2648148984271 5668619178376 495140428796 5570034058080 7844714247724 324634154543 3087905355809 22909504139876 784663794606 4973976072847 12580674106 14960179288492 11294234658777 482646064102 2339337364573 22679401106191 1334310362409 489271116946 809593662...
result:
ok 100000 numbers
Test #24:
score: 20
Accepted
time: 811ms
memory: 83388kb
input:
100000 100000 334637052 806195540 363358406 439507847 457589021 934731957 449465201 635359926 411815924 550005796 332440140 510392600 427357510 541195363 200194121 500001535 409072719 787768202 186689720 577015782 34009564 419688475 78505020 199378026 454786282 677626082 420700145 856988589 20865071...
output:
14293319455 4309002117152 3519091179166 4724687439551 3071910291748 1561428702301 418800747610 7054484136116 4495490595744 4919435161531 1049538308832 7373084770478 1891094424690 985583861919 721836749978 3801762884205 3671130882049 1668881184056 4165599384675 1782563225602 1211553659030 82797404666...
result:
ok 100000 numbers
Test #25:
score: 20
Accepted
time: 902ms
memory: 83848kb
input:
100000 100000 29088604 189163625 279923382 334676734 271040901 672934307 299620349 647700256 206152530 292298743 74369942 91957137 182072363 283099120 146507995 367654364 446672553 495293216 176531974 504858292 361380872 421212364 32178930 467780335 137366788 483788608 203313226 535311966 383683953 ...
output:
412369777227 16851705178447 422913729817 7919872713487 4611619504438 81245796670 14372310985716 187347606911 19040647907051 51264683605 3253344684405 23436004034094 22406561795002 288665240560 1033784582711 319846863052 167259641081 2900608079783 4268243087455 8436890128398 11836503978002 1105595334...
result:
ok 100000 numbers
Test #26:
score: 20
Accepted
time: 801ms
memory: 83564kb
input:
100000 100000 4 11 18 27 5 11 4 7 14 24 8 15 10 15 16 35 10 20 12 29 14 22 13 30 17 18 5 21 7 25 19 30 12 15 5 9 9 28 11 14 5 23 6 16 14 30 20 37 4 19 9 24 1 10 17 36 1 12 9 12 14 19 13 22 15 30 1 19 16 25 17 18 1 19 12 23 5 8 16 32 17 20 16 28 17 30 3 6 12 19 14 26 18 22 8 16 1 2 4 23 8 13 8 26 17 ...
output:
554822 217105 13972 22129 17275 188231 130037 785096 781147 157309 89329 879648 1113949 30781 42359 23502 26443 661535 29510 9471 663727 1086 509525 153772 10937 31856 4662 191007 11042 1153 517840 51080 436409 77427 196665 89608 2820 322268 437082 100448 200025 607027 241277 254158 58400 1040188 19...
result:
ok 100000 numbers
Test #27:
score: 20
Accepted
time: 782ms
memory: 83656kb
input:
100000 100000 15 33 13 29 5 16 9 29 18 24 15 29 12 22 1 20 2 20 5 8 12 23 20 24 18 27 6 26 1 3 13 14 2 21 17 36 8 10 13 24 1 19 3 15 1 13 5 19 13 22 1 21 13 25 20 21 17 32 14 31 16 30 3 7 2 11 15 32 7 21 12 26 16 19 9 25 2 4 8 20 1 11 6 11 12 21 19 31 15 26 19 36 11 27 8 12 17 26 1 3 9 16 7 26 13 14...
output:
380262 883764 297429 365885 14325 42112 21509 46643 230028 28620 63251 67458 20306 87466 151269 621 228671 48025 166379 233035 18452 253945 356933 37150 1067759 465661 46316 87698 33324 2661 333175 420632 556083 815484 192506 78270 227817 17409 281639 183912 222405 89833 14918 157914 2551 18674 2607...
result:
ok 100000 numbers
Subtask #6:
score: 20
Accepted
Dependency #3:
100%
Accepted
Test #28:
score: 20
Accepted
time: 976ms
memory: 82220kb
input:
80000 80000 225354689 357421712 256970283 623358975 178383251 591207393 182615894 514317155 100808700 223792723 474091630 934549627 299874379 640509921 465635430 870489677 66892738 194064485 159834884 348499459 238168819 335814593 75986241 170063921 331860127 555061772 141800677 377649941 472424012 ...
output:
1762279935995 152583492030 517144080587 2477220778000 3494153362357 15293260287527 1776576246271 155282093361 2499857870870 162271062808 4370293512337 5413423315291 835337248692 242306033155 549102515584 1791806084707 889433171668 4323772395399 2533800070350 6337224579515 4360220916646 83224464908 5...
result:
ok 40040 numbers
Test #29:
score: 20
Accepted
time: 890ms
memory: 85800kb
input:
80000 80000 466531356 551003849 190558763 390367786 462444921 779506042 370123580 753306808 300258431 659711385 252697279 511279935 44496271 274563035 376949880 707132432 422475659 764554784 167140484 645659252 98255291 537769304 452104417 509385384 21059793 56627313 336723789 701069885 472984029 92...
output:
1798699219643 234273928994 11158454906 1236025818935 17621549995 8431886526 12458103843 6608267925536 3329132139914 429447661710 1320524794237 3452347251370 1513764727820 1172629834209 140415867316 5320987568758 2083959022699 1417968101650 3453475785567 7464097434672 462455431396 1138020946533 16006...
result:
ok 40065 numbers
Test #30:
score: 20
Accepted
time: 924ms
memory: 85460kb
input:
80000 80000 213904970 335874002 11113047 134739857 289282252 478573320 155584174 520238373 74961190 96320075 60611155 456183205 264691501 342673041 279370823 488966819 236824214 611976325 292781630 386954010 181444664 320703964 250701759 598512929 152701579 242954176 74762826 347613326 256568972 755...
output:
14963722157365 3231968115664 371797683828 2387921132369 546980022807 3285168751793 7352242559202 350245316718 3657327775088 24335460700878 218723712872 190624040625 7342794083512 2389496888869 4828837321987 3526258628281 14183087586383 826901119189 4010570301133 2818425026519 11076686884769 67830162...
result:
ok 39907 numbers
Test #31:
score: 20
Accepted
time: 868ms
memory: 80648kb
input:
80000 80000 15 27 14 19 4 17 19 34 18 35 16 27 15 32 7 19 1 6 20 39 17 24 11 12 2 20 12 17 15 29 12 23 4 8 9 26 16 29 19 20 12 16 19 29 10 21 11 17 17 35 5 21 5 21 10 28 14 24 2 18 20 32 5 20 17 19 13 18 1 7 2 4 15 34 19 26 10 16 3 16 14 15 2 12 11 24 7 19 1 11 19 31 4 23 11 25 18 24 2 8 13 18 6 9 3...
output:
386649 205524 198324 10595 2168 126147 44304 29416 28 51190 10074 22768 99296 615289 391 74305 368945 12613 74409 360263 180801 16655 399534 116868 7892 25483 88450 505322 1418 20183 39603 299499 244264 26841 84680 240384 330231 10018 62760 95611 28063 827025 93155 124545 12413 264914 28479 120071 5...
result:
ok 40217 numbers
Test #32:
score: 20
Accepted
time: 778ms
memory: 84024kb
input:
80000 80000 18 35 17 35 3 6 5 11 18 24 5 16 15 27 3 6 14 23 17 32 3 4 20 28 20 33 20 33 15 26 7 18 6 11 15 23 14 24 15 24 2 12 1 4 6 17 20 21 5 22 3 14 6 22 11 25 12 14 15 33 17 37 3 19 12 22 18 19 10 21 11 22 3 6 18 29 13 24 18 21 7 8 2 11 14 18 4 8 7 26 8 20 17 19 5 21 3 19 19 20 16 28 2 12 10 17 ...
output:
4318 42859 122049 457908 17993 1328 1550 98 103395 78004 92431 516237 161982 129415 4378 230326 705412 593810 3305 1667 879 3053 619060 43765 573521 20325 111679 96364 333701 72175 216340 18708 320260 257959 6425 135904 34885 280764 120538 59932 150806 548350 13316 180375 1983 186 504368 153650 2172...
result:
ok 40053 numbers
Test #33:
score: 20
Accepted
time: 1279ms
memory: 90928kb
input:
100000 100000 226837277 629340960 15356399 333988987 162106984 242750700 20082551 287851579 328071230 610388303 447593817 635405442 308736977 631719320 160200347 397247869 38277427 234064577 409441918 822798349 223535688 308685188 241171327 731560435 88999572 520819667 160876761 423873769 318618403 ...
output:
4896011847309 4193922187123 7267538159374 3009123033669 1150742787800 7376539231054 29986308174812 23514287962586 412292257966 431268376937 134374636779 4204584001628 6206145447825 2252898231053 4733304331 83360655662 3038841452167 1583402488870 7302689839462 13356634900697 8256846109573 48628772165...
result:
ok 50161 numbers
Subtask #7:
score: 30
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Test #34:
score: 30
Accepted
time: 1357ms
memory: 92016kb
input:
100000 100000 229800237 722100077 43222268 521633530 194823742 296704281 34182355 312809937 77732257 273405549 102344836 351041358 395310846 551885672 432455924 824266021 377114525 517074442 241507899 704037560 462989507 476000772 226624645 392513169 84406407 301855054 403836860 780188676 451883792 ...
output:
572846633944 2889552313595 1246863931555 5030364036191 6743532540082 14439802479060 6812934247082 12082383982805 7274264760871 826327698429 5227199517735 509711027681 2908963089992 5025644378159 4996230167952 9857993025 9669151706423 95982662658 1519656247 2464410485616 16224520093277 4176190948 257...
result:
ok 50124 numbers
Test #35:
score: 30
Accepted
time: 1068ms
memory: 92468kb
input:
100000 100000 322903126 779528687 225929646 226849544 166982492 407140204 124023177 417756998 385758152 875610088 370143922 527551261 420494641 717158590 298294232 500025706 257468723 748040415 473979332 493843048 370708669 723572629 299702647 501193098 117383912 543482631 41886972 417906103 4531188...
output:
15882170866165 14418990597967 1485375698727 14493006946914 4261182164597 6136802352059 1190916982513 105803632338 4719099563475 299234101385 313468705501 796368729779 5624651440466 5163655923282 565647163118 61569871798 170115526705 5786632884514 139993180849 19433407147309 3337635033 3045305849926 ...
result:
ok 50160 numbers
Test #36:
score: 30
Accepted
time: 1132ms
memory: 91024kb
input:
100000 100000 8 27 5 18 11 22 20 40 3 17 4 17 7 25 4 9 1 3 4 22 3 21 2 8 3 11 11 31 13 32 17 34 10 30 12 28 3 21 7 20 8 24 4 23 9 23 4 13 14 33 11 25 3 22 2 19 4 21 6 24 7 24 11 23 1 18 5 24 5 17 9 26 1 17 6 17 12 27 11 29 4 15 15 35 8 20 1 18 4 8 9 28 5 19 7 23 1 13 8 25 2 16 12 32 5 25 9 26 5 23 1...
output:
800339 9312 114485 240144 19889 152838 52372 24634 1317968 1658641 318 545696 321816 10154 124654 159687 80885 50345 100202 32027 188921 16927 22787 2270 317537 321 21067 4697 29860 74145 1018470 619029 545825 2770 291139 1749085 18851 64003 117020 81914 21082 5 50396 26730 132007 108304 279448 8385...
result:
ok 50171 numbers
Test #37:
score: 30
Accepted
time: 1096ms
memory: 91128kb
input:
100000 100000 64801697 315632512 227872388 364810332 73187539 339809381 281608373 485275773 30170198 221808337 297409323 433956574 96597790 491239499 73205665 106408453 82450909 108224580 83703494 348384307 89632365 108834186 297524970 488061059 164251065 301275146 281309907 508188457 472271256 6078...
output:
6004891767080 315624773249 6919325461234 5756982057006 33962926881433 418718483950 6217632452838 8618956964 316293469803 20636283104952 10383925288709 27253323737 173628960746 3565551645977 2380123164617 878245225901 1395761159338 12230915005749 2141002682945 14399158968019 835320635999 130217234713...
result:
ok 50136 numbers
Test #38:
score: 30
Accepted
time: 1206ms
memory: 90572kb
input:
100000 100000 89504252 308122414 38107571 467517790 162131655 368900247 231602920 567418451 113524833 587438624 452599416 500886863 152177485 374383275 15560718 405461351 189461210 408685023 452824470 809374999 187265866 219172246 411472572 818555255 325093622 734296072 498950106 709769225 97384885 ...
output:
941175624259 4049841659456 173142362304 4071386059333 3717584414601 5456748417726 4889482629281 355236758567 5056595684187 8083564845 4664680587492 1526768872535 11725203977528 617191629055 1857267311697 202895082474 1402871671888 2150307444875 10662581432675 3470261974845 3107419758574 883761100063...
result:
ok 49870 numbers
Test #39:
score: 30
Accepted
time: 1109ms
memory: 91212kb
input:
100000 100000 152241212 227669303 146067715 401950385 258705053 526116832 483074168 498470216 72171769 96706680 340680054 806796175 96561016 278756565 265124711 679463251 133673746 523176431 452068587 497939301 376773538 508029668 314094382 609529958 225003742 448223199 63618655 353251125 319482000 ...
output:
5765460862277 3525544759155 2098225240303 3298860826771 2918685762512 44455901203 178837470461 795319226558 6537024818811 1709592736733 8206945343 2642971689148 1651475564876 19431796776817 5447065821315 57227946028 9956821918304 6854518207600 3591166951174 4532220674092 15127357914954 3732358700618...
result:
ok 50006 numbers
Test #40:
score: 30
Accepted
time: 1108ms
memory: 92016kb
input:
100000 100000 7 14 10 17 10 16 6 14 4 5 10 17 5 11 5 15 7 10 1 2 1 2 1 6 3 8 5 14 10 12 9 17 2 10 8 14 4 14 1 7 6 16 3 12 2 8 1 5 6 9 8 18 9 12 7 8 3 9 9 12 3 10 3 12 3 13 8 10 7 17 9 16 4 5 8 16 8 18 5 15 5 6 2 6 10 15 9 10 5 10 2 9 7 8 9 16 7 16 1 2 7 13 7 8 5 14 1 11 3 13 10 19 5 15 2 8 10 12 6 9...
output:
186741 53501 112 19868 541838 88546 99077 539985 7965 97273 297133 190940 12390 62676 123732 125297 86994 84227 16368 344883 14535 201320 38994 470 207281 160879 41657 199790 96964 390649 18694 78909 5901 3056 204238 51519 23547 34964 302799 76126 155915 24409 119022 355760 138463 315667 144454 7425...
result:
ok 50242 numbers