QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#942048#9032. 末日时在做什么?有没有空?可以来拯救吗?zhenghanyunAC ✓682ms38532kbC++1411.3kb2025-03-18 21:14:192025-03-18 21:14:27

Judging History

This is the latest submission verdict.

  • [2025-03-18 21:14:27]
  • Judged
  • Verdict: AC
  • Time: 682ms
  • Memory: 38532kb
  • [2025-03-18 21:14:19]
  • Submitted

answer

#include <bits/stdc++.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

namespace IO {
	#ifndef ONLINE_JUDGE
	#define gh() getchar()
	#else
	#define gh() (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, (1 << 20) + 1, stdin), (iS == iT ? EOF : *iS++) : *iS++)
	#endif

	char ibuf[(1 << 20) + 1], *iS, *iT, out[(1 << 26) + 1];
	ui len = 0;

	inline int read() {
		char ch = gh();
		int res = 0, t = 1;
		while (ch < '0' || ch > '9') {
			t = (ch ^ '-') ? t : -1;
			ch = gh();
		}
		while (ch >= '0' && ch <= '9') {
			res = res * 10 + (ch ^ 48);
			ch = gh();
		}
		return t * res;
	}

	inline ui uread() {
		char ch = gh();
		ui res = 0;
		while (ch < '0' || ch > '9') {
			ch = gh();
		}
		while (ch >= '0' && ch <= '9') {
			res = res * 10 + (ch ^ 48);
			ch = gh();
		}
		return res;
	}

	inline void putc(char ch) {
		out[len++] = ch;
	}

	inline void write(ll x) {
		if (x > 9) {
			write(x / 10);
		}
		out[len++] = x % 10 + 48;
	}

	inline void flush() {
		fwrite(out, 1, len, stdout);
		len = 0;
	}
}

using IO::read;
using IO::uread;
using IO::write;
using IO::flush;
using IO::putc;

const ui N = 1 << 17;
const ui unit = 950;
const ui base = 255;

struct node {
	ui x; ll y;
	
	node() {}
	node(ui x, ll y): x(x), y(y) {}
	
	inline node operator+(const node &rhs) const {
		return node(x + rhs.x, y + rhs.y);
	}
	
	inline node operator-(const node &rhs) const {
		return node(x - rhs.x, y - rhs.y);
	}
	
	inline bool operator<(const node &rhs) const {
		return y * rhs.x < x * rhs.y;
	}
} *S, *T, *tmp, *x, *y, *S1, *T1, *S2, *T2, *S3, *T3, la, d1, d2;

struct Ans {
	ll sum, pre, suf, res;
	
	Ans() {}
	Ans(ll sum, ll pre, ll suf, ll res): sum(sum), pre(pre), suf(suf), res(res) {}
	
	inline Ans operator+(const Ans &rhs) const {
		return Ans(sum + rhs.sum, max(pre, sum + rhs.pre), max(rhs.suf, rhs.sum + suf), max(max(res, rhs.res), suf + rhs.pre));
	}
};

ui n, m, k, st[1 << 9], ed[1 << 9], op[N], l[N], r[N], cnt1[14][(1 << 13) + 16], cnt2[14][(1 << 13) + 16], cnt3[14][(1 << 13) + 16];
int a[N], b[1 << 14], d[N];
ll sum[13][(1 << 14) + 16], laz[13][(1 << 14) + 16], maxx;

struct lin {
	ull val;
	lin *Next;
	
	lin() {}
	lin(ull val, lin *Next): val(val), Next(Next) {}
} sor1[N], sor2[N], sor3[N], sor4[N], sor5[N];

lin *tot1, *tot2, *tot3, *tot4, *tot5;
lin *head1[base + 1], *head2[base + 1], *head3[base + 1], *head4[base + 1], *head5[base + 1];
lin *tail1[base + 1], *tail2[base + 1], *tail3[base + 1], *tail4[base + 1], *tail5[base + 1];

node lmax[13][(1 << 14) + 16], rmax[13][(1 << 14) + 16], tres[(1 << 14) + 16], res[13][(1 << 14) + 16];
Ans ans[N];

inline void push_up(const ui dep, const ui l, const ui r, const ll lsum, const ll rsum) {
	const ui mid = (l + r) >> 1;
	const ui l1 = cnt1[dep + 1][l], l2 = cnt1[dep + 1][mid + 1];
	const ui r1 = cnt2[dep + 1][l], r2 = cnt2[dep + 1][mid + 1];
	const ui rl1 = cnt3[dep + 1][l], rl2 = cnt3[dep + 1][mid + 1];
	const node nd1 = node(mid - l + 1, lsum), nd2 = node(r - mid, rsum);
	memcpy(&lmax[dep][l], &lmax[dep + 1][l], sizeof(node) * l1);
	memcpy(&rmax[dep][r - r2 + 1], &rmax[dep + 1][r - r2 + 1], sizeof(node) * r2);
	S = &lmax[dep + 1][mid + 1], T = &lmax[dep + 1][mid + l2];
	tmp = &lmax[dep][l], x = &lmax[dep][l + l1 - 1], y = &lmax[dep][l + l1 - 2];
	while (S <= T) {
		while (y >= tmp && (*x - *y) < (*S + nd1 - *y)) {
			--x, --y;
		}
		++x, ++y;
		*x = *S + nd1;
		++S;
	}
	cnt1[dep][l] = x - tmp + 1;
	S = &rmax[dep + 1][mid], T = &rmax[dep + 1][mid - r1 + 1];
	tmp = &rmax[dep][r], x = &rmax[dep][r - r2 + 1], y = &rmax[dep][r - r2 + 2];
	while (S >= T) {
		while (y <= tmp && (*x - *y) < (*S + nd2 - *y)) {
			++x, ++y;
		}
		--x, --y;
		*x = *S + nd2;
		--S;
	}
	cnt2[dep][l] = tmp - x + 1;
	S1 = &rmax[dep + 1][mid], S2 = &lmax[dep + 1][mid + 1];
	T1 = &rmax[dep + 1][mid - r1 + 1], T2 = &lmax[dep + 1][mid + l2];
	la = *S1 + *S2, d1 = *(S1 - 1) - *S1, d2 = *(S2 + 1) - *S2;
	tres[l + 1] = la;
	while (S1 > T1 && S2 < T2) {
		if (d2 < d1) {
			la = la + d1;
			--S1, d1 = *(S1 - 1) - *S1;
		} else {
			la = la + d2;
			++S2, d2 = *(S2 + 1) - *S2;
		}
		tres[l + la.x - 1] = la;
	}
	while (S1 > T1) {
		la = la + *(S1 - 1) - *S1, --S1;
		tres[l + la.x - 1] = la;
	}
	while (S2 < T2) {
		la = la + *(S2 + 1) - *S2, ++S2;
		tres[l + la.x - 1] = la;
	}
	S1 = &res[dep + 1][l], S2 = &res[dep + 1][mid + 1];
	res[dep][l] = node(1, max(S1 -> y, S2 -> y));
	++S1, ++S2;
	T1 = &res[dep + 1][l + rl1 - 1], T2 = &res[dep + 1][mid + rl2];
	while (S1 <= T1) {
		node &p = tres[l + (S1 -> x) - 1];
		if (!p.x) {
			p = *S1;
		} else {
			p.y = max(p.y, S1 -> y);
		}
		++S1;
	}
	while (S2 <= T2) {
		node &p = tres[l + (S2 -> x) - 1];
		if (!p.x) {
			p = *S2;
		} else {
			p.y = max(p.y, S2 -> y);
		}
		++S2;
	}
	S1 = &res[dep][l], S2 = &tres[l + 1], T2 = &tres[r];
	x = &res[dep][l], y = &res[dep][l - 1];
	while (S2 <= T2) {
		if (S2 -> x) {
			while (y >= S1 && (*x - *y) < (*S2 - *y)) {
				--x, --y;
			}
			++x, ++y;
			*x = *S2;
			*S2 = node(0, 0);
		}
		++S2;
	}
	cnt3[dep][l] = x - S1 + 1;
	sum[dep][l] = lsum + rsum;
}

inline void add(const ui dep, const ui l, const ui r, const ll t) {
	S1 = &lmax[dep][l], S2 = &rmax[dep][r], S3 = &res[dep][l];
	T1 = &lmax[dep][l + cnt1[dep][l] - 1], T2 = &rmax[dep][r - cnt2[dep][l] + 1], T3 = &res[dep][l + cnt3[dep][l] - 1];
	while (S1 <= T1) {
		S1 -> y += (S1 -> x) * t, ++S1;
	}
	while (S2 >= T2) {
		S2 -> y += (S2 -> x) * t, --S2;
	}
	while (S3 <= T3) {
		S3 -> y += (S3 -> x) * t, ++S3;
	}
	sum[dep][l] += t * (r - l + 1);
}

inline void push_down(const ui dep, const ui l, const ui r) {
	ll t = laz[dep][l];
	if (!t) {
		return;
	}
	const ui mid = (l + r) >> 1;
	laz[dep + 1][l] += t, laz[dep + 1][mid + 1] += t;
	add(dep + 1, l, mid, t), add(dep + 1, mid + 1, r, t);
	laz[dep][l] = 0;
}

inline void build(const ui dep, const ui l, const ui r) {
	laz[dep][l] = 0;
	if (l == r) {
		lmax[dep][l] = rmax[dep][l] = res[dep][l] = node(1, b[l]);
		cnt1[dep][l] = cnt2[dep][l] = cnt3[dep][l] = 1;
		sum[dep][l] = b[l];
		return;
	}
	const ui mid = (l + r) >> 1;
	build(dep + 1, l, mid), build(dep + 1, mid + 1, r);
	push_up(dep, l, r, sum[dep + 1][l], sum[dep + 1][mid + 1]);
}

inline void Sor() {
	lin *S;
	ull tmp = 0;
	for (ui j = 0; j <= base; ++j) {
		S = head1[j];
		head1[j] = tail1[j] = 0;
		while (S) {
			*(++tot2) = lin(S -> val, 0);
			tmp = ((S -> val) >> 8) & base;
			if (!head2[tmp]) {
				head2[tmp] = tail2[tmp] = tot2;
			} else {
				tail2[tmp] -> Next = tot2;
				tail2[tmp] = tot2;
			}
			S = S -> Next;
		}
	}
	for (ui j = 0; j <= base; ++j) {
		S = head2[j];
		head2[j] = tail2[j] = 0;
		while (S) {
			*(++tot3) = lin(S -> val, 0);
			tmp = ((S -> val) >> 16) & base;
			if (!head3[tmp]) {
				head3[tmp] = tail3[tmp] = tot3;
			} else {
				tail3[tmp] -> Next = tot3;
				tail3[tmp] = tot3;
			}
			S = S -> Next;
		}
	}
	for (ui j = 0; j <= base; ++j) {
		S = head3[j];
		head3[j] = tail3[j] = 0;
		while (S) {
			*(++tot4) = lin(S -> val, 0);
			tmp = ((S -> val) >> 24) & base;
			if (!head4[tmp]) {
				head4[tmp] = tail4[tmp] = tot4;
			} else {
				tail4[tmp] -> Next = tot4;
				tail4[tmp] = tot4;
			}
			S = S -> Next;
		}
	}
	for (ui j = 0; j <= base; ++j) {
		S = head4[j];
		head4[j] = tail4[j] = 0;
		while (S) {
			*(++tot5) = lin(S -> val, 0);
			tmp = ((S -> val) >> 32) & base;
			if (!head5[tmp]) {
				head5[tmp] = tail5[tmp] = tot5;
			} else {
				tail5[tmp] -> Next = tot5;
				tail5[tmp] = tot5;
			}
			S = S -> Next;
		}
	}
	tot1 = &sor1[0], tot2 = &sor2[0], tot3 = &sor3[0], tot4 = &sor4[0], tot5 = &sor5[0];
}

inline void get_ans(const ui len) {
	if (__builtin_expect(tot1 == &sor1[0], false)) {
		return;
	}
	Sor();
	ui id = 0;
	ll tmp = 0, x = 0, y = 0;
	S1 = &lmax[0][1], S2 = &rmax[0][len], S3 = &res[0][1];
	T1 = &lmax[0][cnt1[0][1]], T2 = &rmax[0][len - cnt2[0][1] + 1], T3 = &res[0][cnt3[0][1]];
	Ans now;
	lin *S;
	for (ui j = 0; j <= base; ++j) {
		S = head5[j];
		head5[j] = tail5[j] = 0;
		while (S) {
			id = (S -> val) >> 42, tmp = ((S -> val) & ((1ll << 42) - 1)) - 4e9;
			x = (S1 -> x) * tmp + (S1 -> y);
			while (S1 < T1) {
				y = ((S1 + 1) -> x) * tmp + ((S1 + 1) -> y);
				if (x > y) {
					break;
				}
				x = y, ++S1;
			}
			now.pre = x;
			x = (S2 -> x) * tmp + (S2 -> y);
			while (S2 > T2) {
				y = ((S2 - 1) -> x) * tmp + ((S2 - 1) -> y);
				if (x > y) {
					break;
				}
				x = y, --S2;
			}
			now.suf = x;
			x = (S3 -> x) * tmp + (S3 -> y);
			while (S3 < T3) {
				y = ((S3 + 1) -> x) * tmp + ((S3 + 1) -> y);
				if (x > y) {
					break;
				}
				x = y, ++S3;
			}
			now.res = x;
			now.sum = sum[0][1] + tmp * len;
			ans[id] = ans[id] + now;
			S = S -> Next;
		}
	}
}

inline void update(const ui ql, const ui qr, const ui dep, const ui l, const ui r, const int t) {
	if (ql <= l && r <= qr) {
		add(dep, l, r, t);
		laz[dep][l] += t;
		return;
	}
	push_down(dep, l, r);
	const ui mid = (l + r) >> 1;
	if (ql <= mid) {
		update(ql, qr, dep + 1, l, mid, t);
	}
	if (qr > mid) {
		update(ql, qr, dep + 1, mid + 1, r, t);
	}
	push_up(dep, l, r, sum[dep + 1][l], sum[dep + 1][mid + 1]);
}

inline void solve(const ui t) {
	const ui L = st[t], R = ed[t], len = R - L + 1;
	for (ui i = 1; i <= len; ++i) {
		b[i] = a[i + L - 1];
	}
	build(0, 1, len);
	ll tag = 0, tmp = 0;
	Ans now;
	int *S, *T;
	for (ui i = 1; i <= m; ++i) {
		if (l[i] > R || r[i] < L) {
			continue;
		}
		if (op[i] ^ 1) {
			if (l[i] <= L && r[i] >= R) {
				tmp = tag + 4e9;
				*(++tot1) = lin(tmp ^ ((ull)i << 42), 0);
				tmp &= base;
				if (!head1[tmp]) {
					head1[tmp] = tail1[tmp] = tot1;
				} else {
					tail1[tmp] -> Next = tot1;
					tail1[tmp] = tot1;
				}
			} else {
				now = Ans(0, 0, 0, 0);
				S = &a[max(l[i], L)], T = &a[min(r[i], R)];
				while (S <= T) {
					tmp = *S + tag;
					now = now + Ans(tmp, tmp, tmp, tmp);
					++S;
				}
				ans[i] = ans[i] + now;
			}
		} else {
			if (l[i] <= L && r[i] >= R) {
				tag += d[i];
			} else {
				const int D = d[i]; 
				get_ans(len);
				S = &a[max(l[i], L)], T = &a[min(r[i], R)];
				while (S <= T) {
					*S += D, ++S;
				}
				update(max(l[i], L) - L + 1, min(r[i], R) - L + 1, 0, 1, len, D);
			}
		}
	}
	get_ans(len);
}

int main() {
	n = uread(), m = uread();
	int *S = a + 1, *T = a + n;
	while (S <= T) {
		*S = read(), ++S;
	}
	if (n <= 50) {
		st[1] = 1, ed[1] = n;
		k = 1;
	} else if (n <= 100) {
		st[1] = 1, ed[1] = 50;
		st[2] = 51, ed[2] = n;
		k = 2;
	} else {
		st[1] = 1, ed[1] = 50; 
		k = 1;
		while (ed[k] < n - 50) {
			++k;
			st[k] = ed[k - 1] + 1, ed[k] = st[k] + unit;
		}
		ed[k] = n - 50;
		++k;
		st[k] = n - 49, ed[k] = n;
	}
	for (ui i = 1; i <= m; ++i) {
		op[i] = uread(), l[i] = uread(), r[i] = uread();
		if (op[i] ^ 2) {
			d[i] = read();
		}
	}
	tot1 = &sor1[0], tot2 = &sor2[0], tot3 = &sor3[0], tot4 = &sor4[0], tot5 = &sor5[0];
	for (ui i = 1; i <= k; ++i) {
		solve(i);
	}
	for (ui i = 1; i <= m; ++i) {
		if (op[i] ^ 1) {
			write(ans[i].res);
			putc('\n');
		}
	}
	flush();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 296ms
memory: 38528kb

input:

100000 100000
-2000 -4000 -6000 -8000 -10000 -12000 -14000 -16000 -18000 -20000 -22000 -24000 -26000 -28000 -30000 -32000 -34000 -36000 -38000 -40000 -42000 -44000 126848597 -48000 -50000 -52000 -54000 -56000 -58000 710122351 -62000 -64000 -66000 -68000 -70000 -72000 168907281 -76000 -78000 -80000 -...

output:

224330299131
224484010932
224487113565
224487113565
224487113565
224499909735
224587659909
224587659909
224587659909
224478051072
224478051072
224711116656
224525274198
224525274198
224680844073
224706191007
224706191007
224706191007
224706191007
224706191007
224706191007
224706191007
224534108814
2...

result:

ok 49760 numbers

Test #2:

score: 0
Accepted
time: 673ms
memory: 38532kb

input:

100000 100000
-6000 -12000 -18000 -24000 -30000 -36000 -42000 -48000 -54000 -60000 107640521 -72000 -78000 -84000 -90000 -96000 -102000 -108000 -114000 -120000 -126000 -132000 -138000 -144000 -150000 -156000 -162000 -168000 -174000 -180000 -186000 -192000 -198000 -204000 -210000 -216000 -222000 -228...

output:

38155993653
1624491933
2293042340
1451817782
1939116588
2292760310
1939109658
23041089003
1939140504
1939140504
1842987569
2114776565
2114776565
30544065393
1451843248
1767699687
2114826167
1589653229
2114826167
4175962389
2114885884
5283568958
2114894067
2114894067
15994793904
4175962389
1476744961...

result:

ok 49824 numbers

Test #3:

score: 0
Accepted
time: 646ms
memory: 38524kb

input:

100000 100000
-441495066 -117107376 -77936481 -89486783 -37574746 -696286923 -147372805 -364415940 -114004101 -112930811 -257264839 -261967327 -20202307 -661362251 -552197012 3432174 -120644139 -677479409 -306349045 -6587185 -5285065 -30635081 -404549659 -421881213 -323624665 -211990715 -363251615 9...

output:

993944513
881619542
918216997
993955454
993955454
984214317
993955454
950000892
993984632
970347807
994009343
994009343
964332708
982251315
708005004
993969839
993973094
993973094
984569532
993973094
708007574
993997823
982259275
994014536
994014536
918232923
994014536
984213235
984213235
994014536
...

result:

ok 49822 numbers

Test #4:

score: 0
Accepted
time: 646ms
memory: 37844kb

input:

100000 100000
521 -601077925 -37844607 -225115227 -776053398 -563476585 870 -65665473 -188327311 -366812662 -436968029 -140024347 -23648785 -229524751 -309813426 -143174473 -210634957 -4538776 -29712277 -110630844 -89032901 -451306177 335 -21806156 -19348579 -802798648 -28903777 -17032261 -51080001 ...

output:

990038893
990016936
990016936
978156041
990035005
954846142
990049673
954846142
978166627
990068995
900219167
641742055
601453435
978166826
978166826
990068995
990068995
892932031
919686229
978162812
978162812
990060967
990051235
922501741
990051235
902354812
990053937
990040927
978166396
919692878
...

result:

ok 49821 numbers

Test #5:

score: 0
Accepted
time: 570ms
memory: 38528kb

input:

100000 100000
-6000 -12000 -339946631 -167807367 -30000 -36000 -198851599 -48000 -54000 -60000 -119142563 -218805537 -128141861 -6880143 -90000 -96000 -102000 -91284821 -380987745 -120000 -52958110 -498246721 -138000 -857959121 -27353533 -156000 -162000 -168000 -417746033 -180000 -186000 -192000 -19...

output:

970347241
970347515
970341197
970341197
970341197
970350358
970352399
970352399
970352399
970352673
970352673
970352673
970352673
970352673
970352673
970352673
970352673
970352673
970352673
970345921
970345921
970345921
970345921
970345921
970355350
970352937
970352937
970352937
970348741
970366771
...

result:

ok 70255 numbers

Test #6:

score: 0
Accepted
time: 648ms
memory: 37344kb

input:

100000 100000
-765494676 -487176774 -18000 -24000 -143410645 -36000 -42000 -48000 -54000 -147780221 -66000 -323794837 -78000 -84000 -90000 -96000 -102000 -286247677 -62726337 -120000 -126000 -162002457 -465441043 -144000 -59710351 -214809410 -162000 -65858651 -174000 -180000 -186000 -192000 -4132314...

output:

799554416
928756407
928767959
857653881
799597437
928775768
853721733
928775768
853734795
663875770
928766338
799591901
928766338
853723292
928766338
853716099
928766338
799576644
663841130
928766338
928766338
799576353
928767593
928767593
928768342
799569791
928761288
928761288
663834277
853713435
...

result:

ok 49864 numbers

Test #7:

score: 0
Accepted
time: 522ms
memory: 37712kb

input:

100000 100000
-17139841 -10751161 -9678325 -13873587 -22362673 -12034213 87775246 -24380189 -18827152 -4775626 41123061 -3053362 -14321389 -1961425 -22761666 -29620795 -3485749 96663665 -6450091 -27419126 -24345748 -25452645 -21245176 41342217 83967581 38040894 -12783721 -20392321 58618102 -8792521 ...

output:

1191141586
1191141586
1191141586
1191141586
1191141586
1191141586
1191141586
1191141586
1191141586
1191141586
1191141586
1185687077
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
1184719331
118...

result:

ok 79936 numbers

Test #8:

score: 0
Accepted
time: 426ms
memory: 37704kb

input:

100000 100000
-1343874 -363939 -48893526 -1378579 -1318544 -1271984 -35341053 -1655640 -2388125 -1572874 -169439 -1381607 -340586 -2531171 -1646527 -1804953 -853835 -440787 -258134 -99599 -2420511 -4885180 -55775 -229749 -159224 -10462841 -130039 -1586795 -45684941 -33722639 -2165600 -2397959 -82214...

output:

0
1
1
1
1
1
1
7519
1
1
0
7123
0
7539
10349
2091
25517
9216
25517
19544
16754
25517
19564
25517
9098
16241
19564
25517
19564
25517
19544
12900
25517
18633
19892
18633
25517
25517
25517
23026
25517
10849
21767
21767
22854
25517
25517
25517
0
7535
23026
23026
23026
21767
22683
23026
22854
25507
25507
2...

result:

ok 80021 numbers

Test #9:

score: 0
Accepted
time: 638ms
memory: 38424kb

input:

100000 100000
-6000 -12000 -18000 -24000 -30000 -69517 -42000 -48000 -54000 -165697 -66000 -72000 -3809 -65505 -90000 -96000 -114589 -172870 -114000 -120000 -126000 -64978 -138000 -144000 -95164 -156000 -162000 -180351 -185524 -180000 -186000 -161801 -12045 -204000 -210000 -216000 -222000 -228000 -2...

output:

0
0
0
0
0
0
384
384
384
3964
1584
0
0
0
0
0
0
0
1584
0
0
0
0
1584
0
0
0
0
0
0
0
0
0
1584
0
0
0
0
0
0
0
0
1613
8767
8767
273
273
0
0
0
0
0
1419
3261
2411
3261
9207
9207
9207
9207
9207
9207
9207
9207
9207
9207
9207
9207
9207
9207
13024
13024
25359
23850
23850
53877
53877
53877
53877
29187
19830
19830
...

result:

ok 49838 numbers

Test #10:

score: 0
Accepted
time: 251ms
memory: 36432kb

input:

100000 100000
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74...

output:

42149971
42149971
4062675
4062675
4062675
205761
205761
19900
0
15930190
15930190
0
0
0
0
0
0
0
0
10118251
36095256
36095256
36095256
36095256
36095256
36095256
739936
43258951
43258951
43258951
28023841
89518890
89518890
89518890
89518890
210483903
210483903
210483903
210483903
210483903
348308421
...

result:

ok 50076 numbers

Test #11:

score: 0
Accepted
time: 262ms
memory: 36224kb

input:

100000 100000
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74...

output:

3191601
0
41364060
71299711
173417376
323431461
209111475
129725778
217225746
152172735
43258951
0
25215651
554931
17202045
0
16471
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
905185
648091
0
0
0
0
6765681
0
0
0
1264845
0
7059403
1412040
13789126
0
0
1003236
1043290
46267390
918690
3083886
0
0
0
0
0...

result:

ok 50000 numbers

Test #12:

score: 0
Accepted
time: 524ms
memory: 38132kb

input:

100000 100000
-3117333 -13701084 7 -19718567 -18716710 -1158681 -27887447 3 -5467801 4 -6387521 -26872750 1 -1412473 5 -8151262 -1872021 -21136502 -17699923 -16415605 -25104769 -13874001 -4135884 -6161386 -1627281 -23216141 1 -304961 -2432545 -12692451 -17332561 9 -28146364 -1445005 -15478753 -27566...

output:

30
30
30
30
30
30
30
30
30
17371
12611
12611
12611
12611
12611
12611
12611
12611
12611
12611
12611
7565
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 80146 numbers

Test #13:

score: 0
Accepted
time: 524ms
memory: 38020kb

input:

100000 100000
-23381226 -17865558 -7461377 -21887551 -19536081 -9903051 -15120459 -12717773 -204247 -29657701 -23623528 -22277914 -21728939 -17508566 -4943734 -28576954 12081751 -2923681 -469903 96571570 -19789657 -29727216 -26427861 -1635821 -28787476 95186307 -29575635 -407889 16207753 -22454961 7...

output:

1555739896
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1555563928
1552872304
1552872304
1552872304
1552872304
1552872304
1554419512
1554419512
1554419512
1554419512
155...

result:

ok 79915 numbers

Test #14:

score: 0
Accepted
time: 574ms
memory: 37796kb

input:

100000 100000
-1330057 -1200 -1800 -142544741 -170680923 -67411747 -32143853 -20684905 -7659397 -6000 -6600 -7200 -7800 -125113001 -9000 -9600 -10200 -197340133 -37297079 -12000 -35111535 -197593502 -13800 -14400 -15000 -15600 -16200 -16800 -17400 -186865933 -2633641 -19200 -19800 -20400 -21000 -261...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15489
15489
15489
15489
15489
15489
15489
15489
14214
14214
14214
22319
22319
22319
22319
19431
19431
19431
21294
19404
19404
23963
23963
23963
23963
23963
23963
23963
23963
32118
32118
30699
30699
39470
39470
39470
39470
39470
39470
26574
26574
26574
26574
26574
2657...

result:

ok 69941 numbers

Test #15:

score: 0
Accepted
time: 339ms
memory: 37592kb

input:

100000 100000
-6000 -12000 -18000 -127534001 -30000 -98609858 -25457158 -43542779 -25057509 -60000 -66000 -19836475 -78000 -84000 -90000 -74944801 -102000 -108000 -114000 -120000 -126000 -132000 -138000 -144000 -150000 -156000 -162000 -168000 -34354903 -180000 -186000 -192000 -198000 -28787383 -1614...

output:

0
2971
0
0
0
0
0
0
0
123
3798
3798
10688
10688
10688
10688
14755
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6600
6600
12805
7734
7734
7734
7734
7734
7734
7734
12942
12942
12942
12942
12942
12942
12680
12680
12680
12680
26949
26949
26949
26949
26949
26949
34470
34470
34470
34470
3447...

result:

ok 70006 numbers

Test #16:

score: 0
Accepted
time: 680ms
memory: 38528kb

input:

100000 100000
574674277 -947472137 -955947896 998375849 333380204 -77751727 -890330069 179073669 933166756 624628232 155314847 843285335 865137094 -841302633 -305924912 711150244 -491168400 863867176 758611323 247000066 -956613056 -738387543 -520080983 439287013 -221792121 991843628 -857009429 -4046...

output:

9249961633
7842702044017
7105442405671
16597874262
18696228316
19785709992
17960038365
17960038365
13895293372
17960038365
17180262413
17960038365
18696228316
13744274483
3427085768884
26770475868800
3739697038796
756679513242
20052588773909
18696228316
18696228316
17960038365
16597874262
7843721792...

result:

ok 50144 numbers

Test #17:

score: 0
Accepted
time: 676ms
memory: 38524kb

input:

100000 100000
685614232 -990762975 -406928198 -328470148 98490258 -991572169 -258910208 -46200034 -533054341 761981165 20877243 -947731339 -373487644 292946154 50616796 -898100688 -246692189 -661880941 960660031 505437238 53996290 311635584 -599997810 -363932611 -227765137 -714112262 242112880 29140...

output:

18808153240
18808153240
7233332840
294235850179
15797262473
17385378656
16826980935
17597134608
21739436672
17597134608
15610606941
21739436672
18808153240
8041045323508
5412405255165
17825352129569
18808153240
19504904372421
18808153240
18808153240
21739436672
9725730632
18808153240
14263911655
188...

result:

ok 49882 numbers

Test #18:

score: 0
Accepted
time: 680ms
memory: 37868kb

input:

100000 100000
824212933 539289351 814535563 -786645647 101789365 -259452860 -193897135 -948764156 194141112 960600047 370468928 186138633 989253958 -772550153 202563154 -45870092 -172830643 -779154500 -786679269 -38644678 -801102006 469911722 219513371 -556625952 -18147121 773829612 -465466870 39416...

output:

11931943115
25920801311
25920801311
16439833493
16439833493
16439833493
14724755519
14724755519
25920801311
16439833493
16750871125
10829676805
25920801311
25920801311
16439833493
3957220451
326954951887
25920801311
14724755519
25920801311
25920801311
25920801311
25920801311
19576959809
14946439720
...

result:

ok 50229 numbers

Test #19:

score: 0
Accepted
time: 678ms
memory: 37988kb

input:

100000 100000
-65366195 435366798 -809916891 267706628 -766796296 263228974 650890378 -208618196 757086892 -689468376 235453355 11051858 440113408 903749830 422537768 917861310 -963998752 593045448 324986645 716630088 535173610 465216753 473243503 -74290898 -397117829 -105332726 -439910858 -93394786...

output:

12291743299
2168422571
501652382
17557129137
21756326358
21756326358
21814914258
14072543023
10632333131
21814914258
18220459343
10232269481
21814914258
21756326358
21756326358
17557129137
14072543023
21756326358
21814914258
21756326358
18220459343
21756326358
21814914258
15877295602
21814914258
217...

result:

ok 49770 numbers

Test #20:

score: 0
Accepted
time: 682ms
memory: 37452kb

input:

100000 100000
-865878924 426060219 -622877464 -518591954 496669102 -792938817 971329126 992314159 314277579 -244169905 -496433536 -106676848 379985999 -475808234 94525922 -677778994 8938621 806504635 -981906721 -786150212 -846755633 -750847804 654966089 -836204468 704628014 -350773668 -817100987 233...

output:

22904539160
19517785714
15640056890
21204142341
8436724735
23293900369042
56249022552982
32284783462013
13977336492
11639623807
26664435209
26664435209
19517785714
26664435209
26664435209
21204142341
26664435209
22904539160
19517785714
21204142341
16706918848
26664435209
22904539160
19517785714
2290...

result:

ok 49866 numbers

Test #21:

score: 0
Accepted
time: 339ms
memory: 38296kb

input:

100000 100000
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74...

output:

0
0
38927020
38883586
244907504
244876562
241806538
23633946
23633946
167004530
294945722
294945722
219572346
219572346
219572346
219572346
219572346
219572346
219572346
119796558
119796558
119796558
119796558
119796558
54534690
54534690
54534690
54534690
111368810
149205294
249478418
249478418
2494...

result:

ok 50083 numbers