QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402541#8577. 평균 최대화zhaohaikun100 ✓1012ms134960kbC++206.9kb2024-04-30 20:13:402024-04-30 20:13:40

Judging History

你现在查看的是最新测评结果

  • [2024-04-30 20:13:40]
  • 评测
  • 测评结果:100
  • 用时:1012ms
  • 内存:134960kb
  • [2024-04-30 20:13:40]
  • 提交

answer

// MagicDark
#include <bits/stdc++.h>
#define mid ((l + r) >> 1)
#define debug cerr << "\033[32m[" << __LINE__ << "]\033[0m "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T& x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T& x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x *= f;
}
const int N = 3e5 + 10;
int n, m, a[N], id[N], tot, l[N], r[N];
ll s[N];
map <int, vector <int>> mp;
vector <int> v[N], e[N];
ll gcd(ll x, ll y) {return y ? gcd(y, x % y) : x;}
struct frac {// x / y
	ll x, y;
	frac(ll xx = 0, ll yy = 1) {
		x = xx, y = yy;
		ll k = gcd(x, y);
		x /= k, y /= k;
	}
};
frac operator + (frac x, frac y) {
	return (frac) {x.x * y.y + x.y * y.x, x.y * y.y};
}
frac operator - (frac x, frac y) {
	return (frac) {x.x * y.y - x.y * y.x, x.y * y.y};
}
frac operator / (frac x, frac y) {
	return (frac) {x.x * y.y, x.y * y.x};
}
frac operator * (frac x, frac y) {
	return (frac) {x.x * y.x, x.y * y.y};
}
bool operator < (frac x, frac y) {
	return (__int128) x.x * y.y < (__int128) y.x * x.y;
}
bool operator == (frac x, frac y) {
	return (__int128) x.x * y.y == (__int128) y.x * x.y;
}
bool operator <= (frac x, frac y) {
	return (__int128) x.x * y.y <= (__int128) y.x * x.y;
}
bool operator > (frac x, frac y) {
	return (__int128) x.x * y.y > (__int128) y.x * x.y;
}
bool operator >= (frac x, frac y) {
	return (__int128) x.x * y.y >= (__int128) y.x * x.y;
}
frac ans[N];
struct vec {
	ll x, y;
	vec(ll xx = 0, ll yy = 0) { x = xx, y = yy; }
};
vec operator + (vec x, vec y) {
	return (vec) {x.x + y.x, x.y + y.y};
}
vec operator - (vec x, vec y) {
	return (vec) {x.x - y.x, x.y - y.y};
}
vec& operator += (vec& x, vec y) {
	return x = x + y;
}
vec& operator -= (vec& x, vec y) {
	return x = x - y;
}
__int128 cross(vec x, vec y) {
	return (__int128) x.x * y.y - (__int128) x.y * y.x;
}
bool operator < (vec x, vec y) {
	return cross(x, y) < 0;
}
bool operator <= (vec x, vec y) {
	return cross(x, y) <= 0;
}
bool operator > (vec x, vec y) {
	return cross(x, y) > 0;
}
bool operator >= (vec x, vec y) {
	return cross(x, y) >= 0;
}
mt19937 mrand(1);//chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l, int r) {return mrand() % (r - l + 1) + l;}
int rt[N], ls[N], rs[N], sz[N];
vec info[N], sum[N];
void pushup(int num) {
	sum[num] = sum[ls[num]] + sum[rs[num]] + info[num];
	sz[num] = sz[ls[num]] + sz[rs[num]] + 1;
}
int merge(int x, int y) {
	if (!x || !y) return x ^ y;
	if (rnd(1, sz[x] + sz[y]) <= sz[x]) return rs[x] = merge(rs[x], y), pushup(x), x;
	return ls[y] = merge(x, ls[y]), pushup(y), y;
}
pair <int, int> split(int num, vec t) {
	if (!num) return make_pair(0, 0);
	if (info[num] > t) {
		pair <int, int> ret = split(ls[num], t);
		ls[num] = ret.second;
		pushup(num);
		return make_pair(ret.first, num);
	} else {
		pair <int, int> ret = split(rs[num], t);
		rs[num] = ret.first;
		pushup(num);
		return make_pair(num, ret.second);
	}
}
int split2(int num, vec& x) {
	if (!num) return 0;
	if ((x + sum[ls[num]]) > info[num]) {
		x += sum[ls[num]] + info[num];
		return split2(rs[num], x);
	} else {
		ls[num] = split2(ls[num], x);
		pushup(num);
		return num;
	}
}
vec query(int num, vec x) {
	if (!num) return x;
	// debug << "~ " << ((x + sum[ls[num]]).x) << " " << ((x + sum[ls[num]]).y) << endl;
	if ((x + sum[ls[num]]) < info[num]) return query(ls[num], x);
	// debug << sum[ls[num]].x << " " << sum[rs[num]].x << endl;
	// debug << info[num].x << " " << info[num].y << " " << (x + sum[ls[num]] + info[num]).x << " " << (x + sum[ls[num]] + info[num]).y << endl;
	return query(rs[num], x + sum[ls[num]] + info[num]);
}
void ins(int& num, int x) {
	pair <int, int> g = split(num, info[x]);
	num = merge(merge(g.first, x), g.second);
}
void mer(int& num, int x) {
	if (!x) return;
	mer(num, ls[x]), mer(num, rs[x]);
	ls[x] = rs[x] = 0, pushup(x);
	ins(num, x);
}
// void dd(int x) {
// 	if (!x) return;
// 	dd(ls[x]);
// 	// debug << info[x].x << " " << info[x].y << endl;
// 	dd(rs[x]);
// }
frac trans(vec x) {
	return (frac) {x.y, x.x};
}
void dfs(int x) {
	for (int i: e[x]) {
		dfs(i);
		if (sz[rt[x]] < sz[rt[i]]) swap(rt[x], rt[i]);
		// debug << sz[rt[x]] << ' ' << sz[rt[i]] << endl;
		mer(rt[x], rt[i]);
		// debug << x << " " << sz[rt[x]] << endl;
	}
	for (int i: v[x]) info[x] += (vec) {1, a[i]};//, debug << "~ " << i << " " << a[i] << endl;
	// debug << "~ " << info[x].x << ' ' << info[x].y << endl;
	// dd(rt[x]);
	rt[x] = split2(rt[x], info[x]);
	// debug << "@ " << info[x].x << " " << info[x].y << " " << sz[rt[x]] << endl;
	// dd(rt[x]);
	sz[x] = 1, sum[x] = info[x];
	ins(rt[x], x);
	// dd(rt[x]);
	ans[x] = trans(query(rt[x], (vec) {2, a[l[x]] + a[r[x]]}));
	// debug << "#  " << query(rt[x], (vec) {2, a[l[x]] + a[r[x]]}).x << " " << query(rt[x], (vec) {2, a[l[x]] + a[r[x]]}).y << endl;
	// debug << "! " << x << ' ' << l[x] << ' ' << r[x] << " " << ans[x].x << " " << ans[x].y << endl;
	// debug << sz[rt[x]] << endl;
	// debug << rt[x] << endl;
	// debug << "! " << info[rt[x]].x << ' ' << info[rt[x]].y << endl;
}
struct hsh {
	ull operator () (pair <int, int> x) const {
		return ((ull) x.first << 32) | x.second;
	}
};
unordered_map <pair <int, int>, int, hsh> gg;
void initialize(std::vector<int> A) {
	n = A.size();
	F(i, 1, n) mp[a[i] = A[i - 1]].push_back(i), s[i] = s[i - 1] + a[i];//, val[i] = mrand();
	s[n + 1] = s[n];
	set <int> s;
	s.insert(0);
	s.insert(n + 1);
	id[0] = ++tot;
	l[1] = 0, r[1] = n + 1;
	for (auto [i, j]: mp) {
		set <int> w;
		for (int k: j) {
			int g = *prev(s.lower_bound(k));
			w.insert(id[g]);
			v[id[g]].push_back(k);
		}
		for (int k: w) {
			int lst = l[k];
			for (int t: v[k]) {
				if (lst + 1 != t) {
					e[k].emplace_back(id[lst] = ++tot);
					l[tot] = lst;
					r[tot] = t;
				}
				lst = t;
			}
			if (lst + 1 != r[k]) {
				e[k].emplace_back(id[lst] = ++tot);
				l[tot] = lst;
				r[tot] = r[k];
			}
		}
		for (int k: j) s.insert(k);
	}
	F(i, 1, tot) {
		// t[i] = tt[i] = {::s[r[i] - 1] - ::s[l[i]], r[i] - l[i] - 1};
		// dot[i] = make_pair(r[i] - l[i] + 1, ::s[r[i]] - (l[i] == 0 ? 0 : ::s[l[i] - 1]));
		gg[make_pair(l[i], r[i])] = i;
	}
	dfs(1);
}
array <ll, 2> maximum_average(int l, int r) {
	l++, r++;
	if (l + 1 == r) {
		frac ans = {a[l] + a[r], 2};
		return {ans.x, ans.y};
	}
	int id = gg[make_pair(l, r)];
	return {ans[id].x, ans[id].y};
}
/* why?
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 6ms
memory: 28304kb

input:

10
2 4 3 9 9 9 9 9 9 1
2
0 2
0 9

output:

3 1
20 3

result:

ok correct!

Test #2:

score: 0
Accepted
time: 0ms
memory: 28568kb

input:

15
4596730 8340349 4612555 5692442 3914918 5213545 5248236 1276073 3844119 2943960 9231647 5091649 2239006 9139001 4735414
100
7 8
5 6
2 4
0 4
8 9
10 11
3 4
0 1
10 11
10 11
3 4
4 5
12 13
0 2
2 4
11 12
12 14
2 3
7 8
12 14
6 7
4 5
11 12
10 11
7 12
8 9
8 9
0 2
2 3
12 14
7 9
7 9
12 13
10 11
9 11
13 14
8...

output:

2560096 1
10461781 2
14219915 3
27156994 5
6788079 2
7161648 1
4803680 1
12937079 2
7161648 1
7161648 1
4803680 1
9128463 2
11378007 2
5849878 1
14219915 3
7330655 2
16113421 3
10304997 2
2560096 1
16113421 3
6524309 2
9128463 2
7330655 2
7161648 1
4156467 1
6788079 2
6788079 2
5849878 1
10304997 2
...

result:

ok correct!

Test #3:

score: 0
Accepted
time: 95ms
memory: 23452kb

input:

15
962724 8815662 7612372 5708998 125165 5107756 9366378 9514244 2381600 4299006 9423670 8225791 7458292 2315903 7210561
600000
7 8
0 4
6 8
9 10
11 12
4 5
13 14
8 13
9 11
2 3
7 8
9 12
6 8
0 4
0 2
12 13
1 2
8 13
0 3
9 10
4 5
6 7
6 8
6 7
0 2
4 13
3 4
6 7
8 9
6 7
11 12
5 8
0 3
9 13
4 8
4 8
8 9
8 13
4 1...

output:

5947922 1
23224921 5
21262222 3
6861338 1
15684083 2
5232921 2
4763232 1
17052131 3
21948467 3
6660685 1
5947922 1
29406759 4
21262222 3
23224921 5
17390758 3
9774195 2
8214017 1
17052131 3
5774939 1
6861338 1
5232921 2
9440311 1
21262222 3
9440311 1
17390758 3
11643561 2
5834163 2
9440311 1
3340303...

result:

ok correct!

Test #4:

score: 0
Accepted
time: 6ms
memory: 28904kb

input:

15
1 8446287 2 999999 3000000 5533975 3000000 3816891 3000000 7671276 3000000 999999 5836790 8574548 1
23
0 14
1 2
0 1
2 14
0 2
3 11
2 3
4 6
3 4
5 6
4 5
6 8
7 8
6 7
8 10
9 10
8 9
10 11
11 14
12 14
11 12
13 14
12 13

output:

17959923 5
8446289 2
4223144 1
45433481 13
2815430 1
31022140 9
1000001 2
11533975 3
3999999 2
8533975 2
8533975 2
3272297 1
6816891 2
6816891 2
4557092 1
5335638 1
5335638 1
3999999 2
7705669 2
14411339 3
6836789 2
8574549 2
7205669 1

result:

ok correct!

Test #5:

score: 0
Accepted
time: 0ms
memory: 28868kb

input:

15
1 15 16 14 18 13 20 12 22 11 24 10 26 9 1
27
0 14
1 3
0 1
2 3
1 2
3 5
0 3
4 5
3 4
5 7
0 5
6 7
5 6
7 9
0 7
8 9
7 8
9 11
0 9
10 11
9 10
11 13
0 11
12 13
11 12
13 14
0 13

output:

212 15
15 1
8 1
15 1
31 2
15 1
23 2
31 2
16 1
15 1
77 6
16 1
33 2
15 1
109 8
33 2
17 1
15 1
71 5
17 1
35 2
15 1
44 3
35 2
18 1
5 1
211 14

result:

ok correct!

Subtask #2:

score: 6
Accepted

Dependency #1:

100%
Accepted

Test #6:

score: 6
Accepted
time: 0ms
memory: 23692kb

input:

48
225555 4046145 5839635 7194994 4703765 1253415 2526352 3198926 6313532 2368195 5024833 9436074 1792945 7650559 3393464 2402026 7697170 5205463 9830460 5392966 1687150 9984223 3014343 8856776 1412298 9773499 6469768 5802450 758943 2748325 7110370 4498454 2674137 8596714 8823659 9855644 6654297 367...

output:

12206599 2
16509941 2
5912798 1
15017401 3
8515643 2
12206599 2
5804412 1
15017401 3
5912798 1
13283417 3
4942890 1
23458015 4
14460907 2
2897745 1
25333600 3
11880653 3
3961549 1
23037954 5
65608557 13
7613747 1
10545933 2
5912798 1
13283417 3
18983962 3
17655565 3
11270851 2
8261027 2
65608557 13
...

result:

ok correct!

Test #7:

score: 0
Accepted
time: 109ms
memory: 28224kb

input:

50
7121308 7345583 6899063 282017 6341784 3680369 5436234 9663519 633330 6333746 7783999 6482701 567072 4276742 8011254 1944632 5712778 8002712 306241 4160326 5728910 1328677 6357927 2565549 4232827 255999 3544802 2039097 494486 2383883 9963617 175242 2913048 5502915 9123911 4881811 2516781 8926134 ...

output:

2697481 1
12522742 3
14466891 2
6173750 1
2283715 1
4877210 1
6947205 2
4877210 1
15966363 4
75715129 17
15966363 4
12522742 3
3483538 1
3800801 2
1583596 1
2533583 2
69914912 15
2244413 1
37729565 8
7313413 1
2533583 2
5244361 1
15099753 2
10138859 2
37729565 8
8415963 2
2283715 1
10252153 3
369992...

result:

ok correct!

Test #8:

score: 0
Accepted
time: 3ms
memory: 23588kb

input:

50
1 3859136 7745573 6119170 3863010 2 3 4 3498508 5 6608915 6662164 999999 3000000 7880751 3000000 4473437 3000000 7609368 3000000 4750778 3000000 8554401 3000000 5166495 3000000 4156171 3000000 9941061 3000000 7323881 3000000 3334344 3000000 3959127 3000000 999999 6 5 5322820 9189056 4 8127987 797...

output:

185663885 48
21586891 5
3859137 2
13864743 2
11604709 2
4991090 1
17723879 3
1931506 1
21586889 4
82038497 21
10793446 3
145705920 37
5 2
11781677 3
7 2
3498513 2
1749256 1
3968837 1
3498517 3
4757026 1
3304460 1
7662163 2
13271079 2
46850085 11
14271083 4
4626917 1
3999999 2
10880751 2
10880751 2
1...

result:

ok correct!

Test #9:

score: 0
Accepted
time: 0ms
memory: 27172kb

input:

50
1 50 51 49 53 48 55 47 57 46 59 45 61 44 63 43 65 42 67 41 69 40 71 39 73 38 75 37 77 36 79 35 81 34 83 33 85 32 87 31 89 30 91 29 93 28 95 27 97 1
97
0 49
1 3
0 1
2 3
1 2
3 5
0 3
4 5
3 4
5 7
0 5
6 7
5 6
7 9
0 7
8 9
7 8
9 11
0 9
10 11
9 10
11 13
0 11
12 13
11 12
13 15
0 13
14 15
13 14
15 17
0 15
...

output:

1757 32
50 1
51 2
50 1
101 2
50 1
151 4
101 2
51 1
50 1
42 1
51 1
103 2
50 1
177 4
103 2
52 1
50 1
457 10
52 1
105 2
50 1
187 4
105 2
53 1
50 1
333 7
53 1
107 2
50 1
193 4
107 2
54 1
50 1
293 6
54 1
109 2
50 1
987 20
109 2
55 1
50 1
548 11
55 1
111 2
50 1
201 4
111 2
56 1
50 1
152 3
56 1
113 2
50 1
...

result:

ok correct!

Subtask #3:

score: 13
Accepted

Dependency #2:

100%
Accepted

Test #10:

score: 13
Accepted
time: 118ms
memory: 23524kb

input:

240
6858784 4989917 9746109 9800650 9356541 6503323 7401498 4493451 2801567 3386165 2481047 9837911 8949606 8663384 5535990 833163 922389 2217653 4643612 8798924 859732 616449 7786902 4457600 9298353 6097782 1517199 1575123 3272602 8273488 8507227 5716403 4182244 3701458 1150320 7526997 7126600 8466...

output:

8184127 1
3735522 1
3795476 1
1597504 1
4829328 1
7761940 1
1570021 1
6387963 1
9688346 3
1633615 1
10959355 2
11038795 2
4880763 1
3941851 1
7302986 1
15088697 2
17640709 2
2459107 1
12100367 2
14887508 5
6296185 2
876017 2
3082279 1
4435943 1
19546759 2
8377911 2
14987510 3
20631197 3
18398272 3
2...

result:

ok correct!

Test #11:

score: 0
Accepted
time: 114ms
memory: 23784kb

input:

250
9162966 9250357 6273148 7600740 9150271 3440942 4849415 2773878 7306022 1849591 6777991 6901659 4064680 3770893 2377669 3403916 1041109 5311874 292665 7289044 3159603 8135675 2072980 3799891 6274489 6899891 9079095 2442557 7502677 3860726 6264634 6932504 7576167 5899943 684774 526401 3720387 478...

output:

6622897 1
11742785 2
6031433 2
10675715 2
3081051 1
6730651 1
3114029 1
9328707 2
5352729 1
19593921 4
15150407 2
9772981 2
13298615 3
5760826 1
6419440 1
12591217 2
11742785 2
39810154 7
34160076 7
3424227 1
5409254 1
8130335 2
16893087 2
16166441 3
7989493 1
7211306 1
10682015 2
3122301 2
3407344 ...

result:

ok correct!

Test #12:

score: 0
Accepted
time: 7ms
memory: 28584kb

input:

250
1 2 3 4 3023964 5 6 9869160 7 8 9359655 9 10 11 5236313 12 6350687 9627762 13 8024104 6527059 3760432 14 15 8480107 16 5445579 7101107 17 18 19 20 7945165 8246903 21 22 23 5152223 24 25 5367561 5181329 9262413 8141382 9514495 26 27 7821178 28 7804811 4208465 6461584 3421272 6286889 4843702 31961...

output:

218222325 47
193204775 42
3 2
183143121 38
5 2
109375705 21
7 2
3023969 2
1511984 1
109375697 19
1007991 1
898221189 203
11 2
9869167 2
4934583 1
30868282 7
9869173 3
824453783 188
15 2
4679832 1
9359663 2
267350406 61
9359672 3
802051200 181
19 2
262713853 59
21 2
5236325 2
2618162 1
27058793 6
523...

result:

ok correct!

Test #13:

score: 0
Accepted
time: 0ms
memory: 29320kb

input:

250
1 250 251 249 253 248 255 247 257 246 259 245 261 244 263 243 265 242 267 241 269 240 271 239 273 238 275 237 277 236 279 235 281 234 283 233 285 232 287 231 289 230 291 229 293 228 295 227 297 226 299 225 301 224 303 223 305 222 307 221 309 220 311 219 313 218 315 217 317 216 319 215 321 214 32...

output:

2951 10
250 1
251 2
250 1
501 2
250 1
751 4
501 2
251 1
250 1
626 3
251 1
503 2
250 1
877 4
503 2
252 1
250 1
2257 10
252 1
505 2
250 1
2761 12
505 2
253 1
250 1
1633 7
253 1
507 2
250 1
943 4
507 2
254 1
250 1
4279 18
254 1
509 2
250 1
4787 20
509 2
255 1
250 1
2648 11
255 1
511 2
250 1
2903 12
511...

result:

ok correct!

Test #14:

score: 0
Accepted
time: 0ms
memory: 28924kb

input:

127
1 25 6 44 6 25 5 83 5 25 6 44 6 25 4 162 4 25 6 44 6 25 5 83 5 25 6 44 6 25 3 321 3 25 6 44 6 25 5 83 5 25 6 44 6 25 4 162 4 25 6 44 6 25 5 83 5 25 6 44 6 25 2 640 2 25 6 44 6 25 5 83 5 25 6 44 6 25 4 162 4 25 6 44 6 25 5 83 5 25 6 44 6 25 3 321 3 25 6 44 6 25 5 83 5 25 6 44 6 25 4 162 4 25 6 44...

output:

646 5
31 2
13 1
56 3
32 3
25 1
25 1
12 1
15 1
31 2
31 1
16 1
44 1
44 1
115 7
31 2
15 1
56 3
12 1
25 1
25 1
35 3
29 2
31 2
170 3
62 3
83 1
83 1
104 5
31 2
29 2
56 3
35 3
25 1
25 1
12 1
15 1
31 2
31 1
115 7
44 1
44 1
114 7
31 2
15 1
56 3
12 1
25 1
25 1
34 3
14 1
31 2
109 1
174 5
162 1
162 1
35 1
31 2
...

result:

ok correct!

Subtask #4:

score: 7
Accepted

Test #15:

score: 7
Accepted
time: 196ms
memory: 55068kb

input:

300000
1 2 4 4 4 4 3 2 4 4 3 4 4 4 4 4 4 4 4 4 3 4 3 4 4 4 4 4 4 4 4 3 3 4 4 4 3 4 3 4 4 4 4 4 4 4 4 4 4 3 3 4 4 4 3 4 4 3 4 4 4 4 4 4 4 3 2 4 4 4 4 4 4 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 4 4 2 4 4 2 4 4 3 4 4 4 2 3 4 4 4 4 4 4 3 2 4 4 4 2 4 4 4 4 4 4 4 4 4 4 4 2 4 4 4 4 4 4 3 4 4 3 4 4 4 4 4 4 4 4 4...

output:

1041675 278497
23 7
3 2
4 1
3 1
4 1
4 1
7 2
5 2
7 2
56 15
4 1
3 1
7 2
42 11
13 4
4 1
7 2
4 1
4 1
4 1
4 1
4 1
4 1
4 1
7 2
10 3
7 2
7 2
19 5
4 1
7 2
4 1
4 1
4 1
4 1
4 1
4 1
7 2
3 1
18 5
4 1
7 2
4 1
7 2
10 3
7 2
7 2
23 6
4 1
7 2
4 1
4 1
4 1
4 1
4 1
4 1
4 1
4 1
7 2
3 1
18 5
4 1
7 2
4 1
7 2
7 2
4 1
7 2
7...

result:

ok correct!

Subtask #5:

score: 12
Accepted

Dependency #3:

100%
Accepted

Test #16:

score: 12
Accepted
time: 125ms
memory: 27576kb

input:

4000
4344032 9677834 5779172 78801 469320 1789966 1779748 3147679 5049607 6295414 6292231 5874387 8807832 5984181 3228577 3529357 528332 6386101 1795741 5602976 8304581 9750737 24760 627728 7325309 4243675 8356932 6633243 445885 1321623 2252967 181037 8074790 4491070 2320473 8159338 7402667 7485053 ...

output:

11382135 2
19014468 5
2589999 2
7447360 1
20540618 3
6556703 2
5268313 1
18763865 3
4160256 1
5265577 2
33745074 5
6464007 2
18380111 4
5961475 2
3185139 2
7873754 1
28358687 4
3622442 1
8462001 1
36799829 10
7908260 1
5303139 1
23916599 3
38151559 7
3124773 2
5920790 1
3786120 1
3495970 1
45987709 ...

result:

ok correct!

Test #17:

score: 0
Accepted
time: 123ms
memory: 30600kb

input:

5000
5790446 4508837 9162136 7149900 6430421 1083368 7398254 672635 6289758 2685219 3248824 7705887 2673096 4210193 980601 8521989 5854838 7771569 4286354 9314430 2298604 7164231 5788878 8584031 101973 3153368 4450775 689282 512512 1525682 5373630 9650756 2076382 8232162 6919671 9574533 1484038 1977...

output:

4254692 1
28428602 5
11860325 2
44963154 11
2043805 1
16158237 2
3478186 1
4721965 2
67286440 11
6948168 1
4643078 1
23806767 5
13519895 2
407215453 71
56564231 10
15190255 4
11860325 2
13307255 2
22668102 5
6036288 1
14598075 2
5914093 1
112029242 19
5989987 2
16310221 3
2466366 1
5687103 1
1061477...

result:

ok correct!

Test #18:

score: 0
Accepted
time: 7ms
memory: 29680kb

input:

5000
1 4607944 9209259 5347502 4531540 2 4631148 5114154 5933715 8958872 9999015 7211944 8879151 6894166 3723688 3 3340071 4 8339511 5 5412818 3698545 5920965 6 7 4632316 7761575 6047136 8780729 4902685 8 4052029 4707285 9 9106150 8490532 10 5614384 9995766 8159200 11 3778686 12 13 8637120 14 784611...

output:

39748981 8
23696245 4
4607945 2
14556761 2
13817203 2
4939521 1
6388235 1
2265771 1
23696246 5
61345863 13
11848124 3
61345853 9
2315575 1
56714705 8
4872651 1
51600551 7
11047869 2
8723277 1
14892587 2
17210959 2
18957887 2
22985261 3
16051773 2
15773317 2
16091095 2
5308927 1
47876863 6
3723691 2
...

result:

ok correct!

Test #19:

score: 0
Accepted
time: 3ms
memory: 30136kb

input:

5000
1 5000 5001 4999 5003 4998 5005 4997 5007 4996 5009 4995 5011 4994 5013 4993 5015 4992 5017 4991 5019 4990 5021 4989 5023 4988 5025 4987 5027 4986 5029 4985 5031 4984 5033 4983 5035 4982 5037 4981 5039 4980 5041 4979 5043 4978 5045 4977 5047 4976 5049 4975 5051 4974 5053 4973 5055 4972 5057 497...

output:

1950099 316
5000 1
5001 2
5000 1
10001 2
5000 1
15001 4
10001 2
5001 1
5000 1
4167 1
5001 1
10003 2
5000 1
8751 2
10003 2
5002 1
5000 1
45007 10
5002 1
10005 2
5000 1
18337 4
10005 2
5003 1
5000 1
4644 1
5003 1
10007 2
5000 1
37511 8
10007 2
5004 1
5000 1
28343 6
5004 1
10009 2
5000 1
95037 20
10009...

result:

ok correct!

Test #20:

score: 0
Accepted
time: 3ms
memory: 24084kb

input:

255
1 26 7 45 7 26 6 84 6 26 7 45 7 26 5 163 5 26 7 45 7 26 6 84 6 26 7 45 7 26 4 322 4 26 7 45 7 26 6 84 6 26 7 45 7 26 5 163 5 26 7 45 7 26 6 84 6 26 7 45 7 26 3 641 3 26 7 45 7 26 6 84 6 26 7 45 7 26 5 163 5 26 7 45 7 26 6 84 6 26 7 45 7 26 4 322 4 26 7 45 7 26 6 84 6 26 7 45 7 26 5 163 5 26 7 45...

output:

1286 5
33 2
27 2
59 3
34 3
26 1
26 1
13 1
16 1
33 2
32 1
118 7
45 1
45 1
122 7
33 2
16 1
59 3
13 1
26 1
26 1
38 3
31 2
33 2
173 3
108 5
84 1
84 1
109 5
33 2
31 2
59 3
38 3
26 1
26 1
13 1
16 1
33 2
32 1
122 7
45 1
45 1
121 7
33 2
16 1
59 3
13 1
26 1
26 1
37 3
15 1
33 2
110 1
178 5
163 1
163 1
36 1
33...

result:

ok correct!

Test #21:

score: 0
Accepted
time: 3ms
memory: 29168kb

input:

2047
1 29 10 48 10 29 9 87 9 29 10 48 10 29 8 166 8 29 10 48 10 29 9 87 9 29 10 48 10 29 7 325 7 29 10 48 10 29 9 87 9 29 10 48 10 29 8 166 8 29 10 48 10 29 9 87 9 29 10 48 10 29 6 644 6 29 10 48 10 29 9 87 9 29 10 48 10 29 8 166 8 29 10 48 10 29 9 87 9 29 10 48 10 29 7 325 7 29 10 48 10 29 9 87 9 2...

output:

10246 5
39 2
15 1
68 3
40 3
29 1
29 1
16 1
19 1
39 2
35 1
136 7
48 1
48 1
143 7
39 2
19 1
68 3
16 1
29 1
29 1
47 3
37 2
39 2
182 3
122 5
87 1
87 1
124 5
39 2
37 2
68 3
47 3
29 1
29 1
16 1
19 1
39 2
35 1
143 7
48 1
48 1
142 7
39 2
19 1
68 3
16 1
29 1
29 1
46 3
18 1
39 2
113 1
38 1
166 1
166 1
39 1
39...

result:

ok correct!

Test #22:

score: 0
Accepted
time: 6ms
memory: 24368kb

input:

4095
1 30 11 49 11 30 10 88 10 30 11 49 11 30 9 167 9 30 11 49 11 30 10 88 10 30 11 49 11 30 8 326 8 30 11 49 11 30 10 88 10 30 11 49 11 30 9 167 9 30 11 49 11 30 10 88 10 30 11 49 11 30 7 645 7 30 11 49 11 30 10 88 10 30 11 49 11 30 9 167 9 30 11 49 11 30 10 88 10 30 11 49 11 30 8 326 8 30 11 49 11...

output:

20486 5
41 2
31 2
71 3
14 1
30 1
30 1
17 1
20 1
41 2
36 1
142 7
49 1
49 1
150 7
41 2
20 1
71 3
17 1
30 1
30 1
50 3
39 2
41 2
185 3
76 3
88 1
88 1
129 5
41 2
39 2
71 3
50 3
30 1
30 1
17 1
20 1
41 2
36 1
150 7
49 1
49 1
149 7
41 2
20 1
71 3
17 1
30 1
30 1
49 3
19 1
41 2
114 1
194 5
167 1
167 1
40 1
41...

result:

ok correct!

Test #23:

score: 0
Accepted
time: 3ms
memory: 24664kb

input:

5000
1 501 502 500 504 499 506 498 508 497 510 496 512 495 514 494 516 493 518 492 520 491 522 490 524 489 526 488 528 487 530 486 532 485 534 484 536 483 538 482 540 481 542 480 544 479 546 478 548 477 550 476 552 475 554 474 556 473 558 472 560 471 562 470 564 469 566 468 568 467 570 466 572 465 5...

output:

135413 224
501 1
251 1
501 1
1003 2
501 1
376 1
1003 2
502 1
501 1
2507 6
502 1
1005 2
501 1
3511 8
1005 2
503 1
501 1
2258 5
503 1
1007 2
501 1
2761 6
1007 2
504 1
501 1
6529 14
504 1
1009 2
501 1
7537 16
1009 2
505 1
501 1
4273 9
505 1
1011 2
501 1
2389 5
1011 2
506 1
501 1
10567 22
506 1
1013 2
5...

result:

ok correct!

Test #24:

score: 0
Accepted
time: 8ms
memory: 29284kb

input:

5000
1 501 502 500 504 499 506 498 508 497 510 496 512 495 514 494 516 493 518 492 520 491 522 490 524 489 526 488 528 487 530 486 532 485 534 484 536 483 538 482 540 481 542 480 544 479 546 478 548 477 550 476 552 475 554 474 556 473 558 472 560 471 562 470 564 469 566 468 568 467 570 466 572 465 5...

output:

135413 224
501 1
251 1
501 1
1003 2
501 1
376 1
1003 2
502 1
501 1
2507 6
502 1
1005 2
501 1
3511 8
1005 2
503 1
501 1
2258 5
503 1
1007 2
501 1
2761 6
1007 2
504 1
501 1
6529 14
504 1
1009 2
501 1
7537 16
1009 2
505 1
501 1
4273 9
505 1
1011 2
501 1
2389 5
1011 2
506 1
501 1
10567 22
506 1
1013 2
5...

result:

ok correct!

Test #25:

score: 0
Accepted
time: 8ms
memory: 28208kb

input:

5000
1 501 502 500 504 499 506 498 508 497 510 496 512 495 514 494 516 493 518 492 520 491 522 490 524 489 526 488 528 487 530 486 532 485 534 484 536 483 538 482 540 481 542 480 544 479 546 478 548 477 550 476 552 475 554 474 556 473 558 472 560 471 562 470 564 469 566 468 568 467 570 466 572 465 5...

output:

135413 224
501 1
251 1
501 1
1003 2
501 1
376 1
1003 2
502 1
501 1
2507 6
502 1
1005 2
501 1
3511 8
1005 2
503 1
501 1
2258 5
503 1
1007 2
501 1
2761 6
1007 2
504 1
501 1
6529 14
504 1
1009 2
501 1
7537 16
1009 2
505 1
501 1
4273 9
505 1
1011 2
501 1
2389 5
1011 2
506 1
501 1
10567 22
506 1
1013 2
5...

result:

ok correct!

Test #26:

score: 0
Accepted
time: 3ms
memory: 30324kb

input:

5000
1 13191 2 13117 3 14564 4 12841 5 11947 6 11195 7 12561 8 14392 9 14173 10 10705 11 14501 12 11566 13 13912 14 10713 15 13964 16 11257 17 10698 18 10278 19 11654 20 13867 21 10403 22 11762 23 13165 24 10962 25 14600 26 13037 27 14608 28 12205 29 11600 30 10477 31 12329 32 13661 33 11923 34 1229...

output:

17963317 2802
13193 2
6596 1
17939363 2798
4398 1
6560 1
13119 2
8957329 1397
4374 1
7284 1
14567 2
17887789 2790
4857 1
6423 1
12845 2
8931021 1393
12850 3
11953 2
5976 1
8919891 1391
3986 1
5601 1
11201 2
2969572 463
3736 1
12569 2
6284 1
17794461 2774
4192 1
14401 2
7200 1
17769659 2770
4803 1
14...

result:

ok correct!

Test #27:

score: 0
Accepted
time: 7ms
memory: 29548kb

input:

5000
1 7777312 2 8356143 3 7519179 4 8003378 5 8052587 6 7524993 7 5755654 8 4627963 9 7178310 10 4252506 11 5608873 12 8718358 13 7193653 14 9119083 15 7502105 16 6529929 17 7288953 18 6206075 19 8026664 20 9185515 21 7337300 22 8404763 23 9173143 24 5485785 25 9654686 26 6484484 27 7992103 28 7959...

output:

19240167547 4894
3888657 1
7777313 2
3204681676 815
7777315 3
4178073 1
8356145 2
19211228705 4886
8356148 3
7519183 2
3759591 1
9597232902 2441
7519186 3
8003383 2
4001691 1
9588270580 2439
8003387 3
8052593 2
4026296 1
9580175510 2437
8052598 3
3762500 1
7524999 2
9574363632 2435
7525006 3
2877831...

result:

ok correct!

Subtask #6:

score: 17
Accepted

Test #28:

score: 17
Accepted
time: 309ms
memory: 134848kb

input:

300000
1 300000 300001 299999 300003 299998 300005 299997 300007 299996 300009 299995 300011 299994 300013 299993 300015 299992 300017 299991 300019 299990 300021 299989 300023 299988 300025 299987 300027 299986 300029 299985 300031 299984 300033 299983 300035 299982 300037 299981 300039 299980 3000...

output:

458625151 1225

result:

ok correct!

Test #29:

score: 0
Accepted
time: 212ms
memory: 74308kb

input:

262143
1 36 17 55 17 36 16 94 16 36 17 55 17 36 15 173 15 36 17 55 17 36 16 94 16 36 17 55 17 36 14 332 14 36 17 55 17 36 16 94 16 36 17 55 17 36 15 173 15 36 17 55 17 36 16 94 16 36 17 55 17 36 13 651 13 36 17 55 17 36 16 94 16 36 17 55 17 36 15 173 15 36 17 55 17 36 16 94 16 36 17 55 17 36 14 332 ...

output:

1310726 5

result:

ok correct!

Test #30:

score: 0
Accepted
time: 30ms
memory: 36920kb

input:

30000
1 8655519 5053769 2 3 4 5 6991720 3321347 8718018 4464302 8356978 6 7 8 8314637 5910310 3734266 7192139 9183941 9 4352483 6266035 4417558 10 6855725 6999520 4363735 11 12 3499845 8360666 13 14 15 16 9638440 7317746 17 9282787 18 7466678 7930596 9367029 9821794 19 9771448 5441062 6451096 328952...

output:

1506711094 313

result:

ok correct!

Test #31:

score: 0
Accepted
time: 442ms
memory: 95332kb

input:

290000
1 2 6720098 9810682 9668570 8703077 7145578 8284345 5251625 6142206 3 4 5 6 9581548 3001002 3225039 8794590 7 7045505 4451229 5589636 8 5839563 9 4221964 4476182 9093685 6987982 8939207 10 5185060 5575428 4771993 6420287 11 5731640 9062305 12 4033948 6267196 9720880 9696770 8607688 7778692 13...

output:

105901076 21

result:

ok correct!

Test #32:

score: 0
Accepted
time: 493ms
memory: 96572kb

input:

300000
1 8082711 2 3 4 8191165 3057929 5 3281578 6 6806849 5907196 7 9351806 3531744 7705686 6432789 9157615 8 9 6375173 10 11 9085831 12 8260525 5405870 5874520 5080934 9030605 4739400 3087365 13 14 3952382 8426580 15 3670130 3487971 16 9726802 6241396 5894014 9251026 17 3933416 6097186 8936104 857...

output:

54234185 11

result:

ok correct!

Test #33:

score: 0
Accepted
time: 408ms
memory: 97692kb

input:

300000
1 30001 30002 30000 30004 29999 30006 29998 30008 29997 30010 29996 30012 29995 30014 29994 30016 29993 30018 29992 30020 29991 30022 29990 30024 29989 30026 29988 30028 29987 30030 29986 30032 29985 30034 29984 30036 29983 30038 29982 30040 29981 30042 29980 30044 29979 30046 29978 30048 299...

output:

32735599 877

result:

ok correct!

Test #34:

score: 0
Accepted
time: 427ms
memory: 97980kb

input:

300000
1 30001 30002 30000 30004 29999 30006 29998 30008 29997 30010 29996 30012 29995 30014 29994 30016 29993 30018 29992 30020 29991 30022 29990 30024 29989 30026 29988 30028 29987 30030 29986 30032 29985 30034 29984 30036 29983 30038 29982 30040 29981 30042 29980 30044 29979 30046 29978 30048 299...

output:

32735599 877

result:

ok correct!

Test #35:

score: 0
Accepted
time: 425ms
memory: 97696kb

input:

300000
1 30001 30002 30000 30004 29999 30006 29998 30008 29997 30010 29996 30012 29995 30014 29994 30016 29993 30018 29992 30020 29991 30022 29990 30024 29989 30026 29988 30028 29987 30030 29986 30032 29985 30034 29984 30036 29983 30038 29982 30040 29981 30042 29980 30044 29979 30046 29978 30048 299...

output:

32735599 877

result:

ok correct!

Test #36:

score: 0
Accepted
time: 367ms
memory: 110960kb

input:

300000
1 100001 100002 100000 100004 99999 100006 99998 100008 99997 100010 99996 100012 99995 100014 99994 100016 99993 100018 99992 100020 99991 100022 99990 100024 99989 100026 99988 100028 99987 100030 99986 100032 99985 100034 99984 100036 99983 100038 99982 100040 99981 100042 99980 100044 999...

output:

49245747 395

result:

ok correct!

Test #37:

score: 0
Accepted
time: 380ms
memory: 110656kb

input:

300000
1 100001 100002 100000 100004 99999 100006 99998 100008 99997 100010 99996 100012 99995 100014 99994 100016 99993 100018 99992 100020 99991 100022 99990 100024 99989 100026 99988 100028 99987 100030 99986 100032 99985 100034 99984 100036 99983 100038 99982 100040 99981 100042 99980 100044 999...

output:

49245747 395

result:

ok correct!

Test #38:

score: 0
Accepted
time: 358ms
memory: 110836kb

input:

300000
1 100001 100002 100000 100004 99999 100006 99998 100008 99997 100010 99996 100012 99995 100014 99994 100016 99993 100018 99992 100020 99991 100022 99990 100024 99989 100026 99988 100028 99987 100030 99986 100032 99985 100034 99984 100036 99983 100038 99982 100040 99981 100042 99980 100044 999...

output:

49245747 395

result:

ok correct!

Test #39:

score: 0
Accepted
time: 420ms
memory: 94844kb

input:

300000
1 1001 1002 1000 1004 999 1006 998 1008 997 1010 996 1012 995 1014 994 1016 993 1018 992 1020 991 1022 990 1024 989 1026 988 1028 987 1030 986 1032 985 1034 984 1036 983 1038 982 1040 981 1042 980 1044 979 1046 978 1048 977 1050 976 1052 975 1054 974 1056 973 1058 972 1060 971 1062 970 1064 9...

output:

11533623 9449

result:

ok correct!

Test #40:

score: 0
Accepted
time: 414ms
memory: 95008kb

input:

300000
1 1001 1002 1000 1004 999 1006 998 1008 997 1010 996 1012 995 1014 994 1016 993 1018 992 1020 991 1022 990 1024 989 1026 988 1028 987 1030 986 1032 985 1034 984 1036 983 1038 982 1040 981 1042 980 1044 979 1046 978 1048 977 1050 976 1052 975 1054 974 1056 973 1058 972 1060 971 1062 970 1064 9...

output:

11533623 9449

result:

ok correct!

Test #41:

score: 0
Accepted
time: 406ms
memory: 94756kb

input:

300000
1 1001 1002 1000 1004 999 1006 998 1008 997 1010 996 1012 995 1014 994 1016 993 1018 992 1020 991 1022 990 1024 989 1026 988 1028 987 1030 986 1032 985 1034 984 1036 983 1038 982 1040 981 1042 980 1044 979 1046 978 1048 977 1050 976 1052 975 1054 974 1056 973 1058 972 1060 971 1062 970 1064 9...

output:

11533623 9449

result:

ok correct!

Test #42:

score: 0
Accepted
time: 341ms
memory: 120568kb

input:

300000
1 843582 2 873021 3 643266 4 825520 5 612939 6 642259 7 867008 8 688306 9 735154 10 728530 11 855292 12 766900 13 680592 14 756837 15 644649 16 886591 17 718665 18 883840 19 603356 20 877389 21 657101 22 799281 23 859838 24 818703 25 708095 26 833634 27 819313 28 837566 29 621548 30 603778 31...

output:

30788603822 79993

result:

ok correct!

Test #43:

score: 0
Accepted
time: 468ms
memory: 105360kb

input:

300000
1 6835493 2 4021139 3 4948020 4 9277118 5 4836220 6 7333822 7 5477584 8 8207990 9 4016733 10 9290125 11 8744708 12 6270566 13 5111629 14 8762765 15 5761419 16 9228542 17 5577763 18 6444537 19 5966457 20 4038485 21 9462991 22 6349304 23 7657234 24 9631830 25 6433737 26 9269204 27 4684626 28 74...

output:

391096243794 97939

result:

ok correct!

Subtask #7:

score: 8
Accepted

Dependency #4:

100%
Accepted

Test #44:

score: 8
Accepted
time: 254ms
memory: 57648kb

input:

300000
1 18 20 20 20 18 20 19 19 20 20 20 20 20 20 20 20 20 20 20 20 20 13 20 18 20 20 20 20 20 20 20 16 20 20 20 20 20 20 19 18 20 20 20 20 20 18 20 20 20 20 19 20 20 20 20 20 20 20 20 20 20 14 19 20 20 19 20 20 20 19 19 20 18 18 12 20 19 20 20 20 20 20 20 20 11 20 20 14 20 19 19 20 20 20 20 20 20 ...

output:

398307 20360
96 5
19 2
20 1
19 1
20 1
19 1
349 18
39 2
19 1
19 1
19 1
292 15
20 1
39 2
20 1
20 1
20 1
20 1
20 1
20 1
20 1
20 1
20 1
20 1
20 1
33 2
1039 54
428 23
19 1
33 2
58 3
17 1
20 1
19 1
20 1
20 1
20 1
20 1
20 1
18 1
604 31
207 11
20 1
18 1
20 1
20 1
20 1
20 1
39 2
37 2
155 8
136 7
173 9
20 1
1...

result:

ok correct!

Subtask #8:

score: 32
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

Dependency #7:

100%
Accepted

Test #45:

score: 32
Accepted
time: 973ms
memory: 124244kb

input:

300000
1722551 1840268 7525588 2333278 5653696 1301791 4516105 5399247 782323 200879 4724124 5581699 4106976 1332121 6870526 5085066 952571 8671935 2987334 6642870 8501148 6617734 1077421 4390688 6873088 6149463 1203475 443937 8063173 4104862 3097592 3926362 1880050 3661774 8031364 9154092 5352685 2...

output:

5428171 2
117972714 23
23804923 5
4733524 1
3315926 1
19696901 3
44840279 10
4298256 1
3985338 1
2865426 1
16423403 3
9066019 2
46425725 9
20368359 5
6223933 4
23067231 4
26278808 5
13593377 3
3872049 2
39027385 9
8045041 1
14013222 5
20360494 3
6445535 2
2337083 1
16368896 3
9779667 2
1244764 1
134...

result:

ok correct!

Test #46:

score: 0
Accepted
time: 937ms
memory: 121268kb

input:

290000
6989116 1752391 3798254 7767321 8617431 4076053 6975047 1004266 4313216 6791296 8639185 6086588 7507204 9355010 5179513 9575163 3568530 6961047 5340370 8837461 3370048 6399681 7798161 5780798 3435653 7888389 2732816 7676781 9710781 7576812 4357583 1673821 6148137 5120131 4570735 4140877 86872...

output:

12269086 3
20731682 3
5546879 1
7713440 3
3387082 1
7348461 1
5246791 1
13125658 3
15410801 2
7654071 2
10220009 2
6323937 2
3815282 1
4421132 1
5412427 1
238065466 47
25919350 3
7826536 1
8934337 2
3395391 2
2498043 2
8985661 2
2714064 1
4938912 1
84700041 19
15576017 3
710334 1
5896321 2
6486649 2...

result:

ok correct!

Test #47:

score: 0
Accepted
time: 1010ms
memory: 124220kb

input:

300000
4758681 8855228 9541737 6152825 1845209 5789607 7290784 6346661 1425107 2097425 671480 2968958 6727128 9850980 1692313 642775 5273995 7608316 3061826 1384887 8716388 6702633 4524739 8440665 1764141 9690416 1625987 6701098 1330440 6385738 2207866 3330383 6773222 8634788 6581560 4323356 4976273...

output:

13767219 4
15554697 4
8779999 2
7852618 1
12655525 3
4060654 1
15100971 2
10562831 2
3481857 1
17045129 5
2694430 1
18805953 4
29473840 7
24704924 3
1758188 1
5275156 1
15236637 4
3150486 1
5866945 2
48969596 7
15605471 4
6657603 1
6489507 1
9356943 2
11312073 2
5247107 1
13762759 2
5048965 1
975825...

result:

ok correct!

Test #48:

score: 0
Accepted
time: 45ms
memory: 33528kb

input:

30000
1 2 7701609 8625351 7073492 6267040 3039952 9403636 5322417 3 8290637 6245661 5106295 6885827 6258392 9718216 5315113 4 5924954 4408585 5 6298065 4648043 4923996 6871378 6 7 8 6612348 5727010 8095033 9628240 9 10 9333177 11 12 3752180 13 8768585 5647543 14 15 7014929 4041192 16 7659518 17 9446...

output:

146637705 29
133635199 25
3 2
23400452 3
7701611 2
15698843 2
8163480 1
6670266 1
11700227 2
4653496 1
29667494 5
4441502 1
5451241 1
14726053 2
6221794 1
2661210 1
17766005 3
62859087 13
47433502 9
7268149 1
4145320 1
5675978 1
14536301 3
33283847 6
4910649 1
13144219 2
5996061 1
21291721 3
1825051...

result:

ok correct!

Test #49:

score: 0
Accepted
time: 632ms
memory: 95936kb

input:

290000
1 8663442 8263939 7915897 2 3 4950635 4 4383286 9917740 4455229 7755280 7641399 5 6124163 6 7 9522998 6019537 8 5970316 4959709 8408758 8314364 9 3143048 10 9386082 11 9246339 9779085 8759762 12 3445013 3962414 8854063 6957800 6164825 8765933 13 14 7276419 15 16 3001768 6423273 17 18 5283814 ...

output:

921838757 184
16927381 2
8663443 2
8089918 1
16927382 3
7915899 2
24843279 4
896995477 179
24843281 5
882443568 175
5 2
4950639 2
2475319 1
96050785 19
1650214 1
11384313 2
2191645 1
14372969 2
7150513 1
19851913 4
6252085 1
15396679 2
12210509 2
3820702 1
19851908 3
819304267 162
34152943 7
6124169...

result:

ok correct!

Test #50:

score: 0
Accepted
time: 644ms
memory: 98000kb

input:

300000
1 4854777 2 3433519 3 5288866 8055555 4 5127074 5 3185237 6740535 3084619 3633939 6 6781297 7582513 5921657 4627005 5720942 7 6018147 6515158 5253013 8 3662938 6421052 7519220 4950618 9 5612831 4739056 3887784 4072902 10 4295249 7135045 11 7429034 6281064 7578106 6127341 6765336 3573927 71237...

output:

61496501 12
4854779 2
2427389 1
1655793101 358
1618260 1
1716761 1
3433521 2
1635404861 353
1144508 1
13344425 3
5288869 2
8055559 2
13344421 2
1622060434 349
3336107 1
5127079 2
2563539 1
1598299685 342
5127083 3
4336797 1
1592621 1
4912577 1
4962886 1
6718564 3
3252599 1
3633945 2
3359279 1
288398...

result:

ok correct!

Test #51:

score: 0
Accepted
time: 37ms
memory: 37444kb

input:

30000
1 30000 30001 29999 30003 29998 30005 29997 30007 29996 30009 29995 30011 29994 30013 29993 30015 29992 30017 29991 30019 29990 30021 29989 30023 29988 30025 29987 30027 29986 30029 29985 30031 29984 30033 29983 30035 29982 30037 29981 30039 29980 30041 29979 30043 29978 30045 29977 30047 2997...

output:

28875311 774
30000 1
30001 2
30000 1
60001 2
30000 1
90001 4
60001 2
30001 1
30000 1
75001 3
30001 1
60003 2
30000 1
52501 2
60003 2
30002 1
30000 1
270007 10
30002 1
60005 2
30000 1
330011 12
60005 2
30003 1
30000 1
195008 7
30003 1
60007 2
30000 1
225011 8
60007 2
30004 1
30000 1
510029 18
30004 1...

result:

ok correct!

Test #52:

score: 0
Accepted
time: 446ms
memory: 134960kb

input:

300000
1 300000 300001 299999 300003 299998 300005 299997 300007 299996 300009 299995 300011 299994 300013 299993 300015 299992 300017 299991 300019 299990 300021 299989 300023 299988 300025 299987 300027 299986 300029 299985 300031 299984 300033 299983 300035 299982 300037 299981 300039 299980 3000...

output:

458625151 1225
300000 1
300001 2
300000 1
600001 2
300000 1
900001 4
600001 2
300001 1
300000 1
750001 3
300001 1
600003 2
300000 1
525001 2
600003 2
300002 1
300000 1
2700007 10
300002 1
600005 2
300000 1
3300011 12
600005 2
300003 1
300000 1
1950008 7
300003 1
600007 2
300000 1
2250011 8
600007 2
...

result:

ok correct!

Test #53:

score: 0
Accepted
time: 162ms
memory: 49104kb

input:

131071
1 35 16 54 16 35 15 93 15 35 16 54 16 35 14 172 14 35 16 54 16 35 15 93 15 35 16 54 16 35 13 331 13 35 16 54 16 35 15 93 15 35 16 54 16 35 14 172 14 35 16 54 16 35 15 93 15 35 16 54 16 35 12 650 12 35 16 54 16 35 15 93 15 35 16 54 16 35 14 172 14 35 16 54 16 35 15 93 15 35 16 54 16 35 13 331 ...

output:

655366 5
51 2
18 1
86 3
52 3
35 1
35 1
22 1
25 1
51 2
41 1
172 7
54 1
54 1
185 7
51 2
25 1
86 3
22 1
35 1
35 1
65 3
49 2
51 2
200 3
30 1
93 1
93 1
154 5
51 2
49 2
86 3
65 3
35 1
35 1
22 1
25 1
51 2
41 1
185 7
54 1
54 1
184 7
51 2
25 1
86 3
22 1
35 1
35 1
64 3
24 1
51 2
119 1
214 5
172 1
172 1
45 1
5...

result:

ok correct!

Test #54:

score: 0
Accepted
time: 328ms
memory: 72232kb

input:

262143
1 36 17 55 17 36 16 94 16 36 17 55 17 36 15 173 15 36 17 55 17 36 16 94 16 36 17 55 17 36 14 332 14 36 17 55 17 36 16 94 16 36 17 55 17 36 15 173 15 36 17 55 17 36 16 94 16 36 17 55 17 36 13 651 13 36 17 55 17 36 16 94 16 36 17 55 17 36 15 173 15 36 17 55 17 36 16 94 16 36 17 55 17 36 14 332 ...

output:

1310726 5
53 2
37 2
89 3
18 1
36 1
36 1
23 1
26 1
53 2
42 1
178 7
55 1
55 1
192 7
53 2
26 1
89 3
23 1
36 1
36 1
68 3
51 2
53 2
203 3
464 15
94 1
94 1
159 5
53 2
51 2
89 3
68 3
36 1
36 1
23 1
26 1
53 2
42 1
192 7
55 1
55 1
191 7
53 2
26 1
89 3
23 1
36 1
36 1
67 3
25 1
53 2
120 1
218 5
173 1
173 1
46 ...

result:

ok correct!

Test #55:

score: 0
Accepted
time: 596ms
memory: 97764kb

input:

300000
1 30001 30002 30000 30004 29999 30006 29998 30008 29997 30010 29996 30012 29995 30014 29994 30016 29993 30018 29992 30020 29991 30022 29990 30024 29989 30026 29988 30028 29987 30030 29986 30032 29985 30034 29984 30036 29983 30038 29982 30040 29981 30042 29980 30044 29979 30046 29978 30048 299...

output:

32735599 877
30001 1
15001 1
30001 1
60003 2
30001 1
22501 1
60003 2
30002 1
30001 1
150007 6
30002 1
60005 2
30001 1
210011 8
60005 2
30003 1
30001 1
135008 5
30003 1
60007 2
30001 1
165011 6
60007 2
30004 1
30001 1
390029 14
30004 1
60009 2
30001 1
450037 16
60009 2
30005 1
30001 1
255023 9
30005 ...

result:

ok correct!

Test #56:

score: 0
Accepted
time: 612ms
memory: 97736kb

input:

300000
1 30001 30002 30000 30004 29999 30006 29998 30008 29997 30010 29996 30012 29995 30014 29994 30016 29993 30018 29992 30020 29991 30022 29990 30024 29989 30026 29988 30028 29987 30030 29986 30032 29985 30034 29984 30036 29983 30038 29982 30040 29981 30042 29980 30044 29979 30046 29978 30048 299...

output:

32735599 877
30001 1
15001 1
30001 1
60003 2
30001 1
22501 1
60003 2
30002 1
30001 1
150007 6
30002 1
60005 2
30001 1
210011 8
60005 2
30003 1
30001 1
135008 5
30003 1
60007 2
30001 1
165011 6
60007 2
30004 1
30001 1
390029 14
30004 1
60009 2
30001 1
450037 16
60009 2
30005 1
30001 1
255023 9
30005 ...

result:

ok correct!

Test #57:

score: 0
Accepted
time: 592ms
memory: 97956kb

input:

300000
1 30001 30002 30000 30004 29999 30006 29998 30008 29997 30010 29996 30012 29995 30014 29994 30016 29993 30018 29992 30020 29991 30022 29990 30024 29989 30026 29988 30028 29987 30030 29986 30032 29985 30034 29984 30036 29983 30038 29982 30040 29981 30042 29980 30044 29979 30046 29978 30048 299...

output:

32735599 877
30001 1
15001 1
30001 1
60003 2
30001 1
22501 1
60003 2
30002 1
30001 1
150007 6
30002 1
60005 2
30001 1
210011 8
60005 2
30003 1
30001 1
135008 5
30003 1
60007 2
30001 1
165011 6
60007 2
30004 1
30001 1
390029 14
30004 1
60009 2
30001 1
450037 16
60009 2
30005 1
30001 1
255023 9
30005 ...

result:

ok correct!

Test #58:

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

input:

300000
1 100001 100002 100000 100004 99999 100006 99998 100008 99997 100010 99996 100012 99995 100014 99994 100016 99993 100018 99992 100020 99991 100022 99990 100024 99989 100026 99988 100028 99987 100030 99986 100032 99985 100034 99984 100036 99983 100038 99982 100040 99981 100042 99980 100044 999...

output:

49245747 395
100001 1
50001 1
100001 1
200003 2
100001 1
75001 1
200003 2
100002 1
100001 1
166669 2
100002 1
200005 2
100001 1
700011 8
200005 2
100003 1
100001 1
450008 5
100003 1
200007 2
100001 1
183337 2
200007 2
100004 1
100001 1
1300029 14
100004 1
200009 2
100001 1
1500037 16
200009 2
100005...

result:

ok correct!

Test #59:

score: 0
Accepted
time: 530ms
memory: 110900kb

input:

300000
1 100001 100002 100000 100004 99999 100006 99998 100008 99997 100010 99996 100012 99995 100014 99994 100016 99993 100018 99992 100020 99991 100022 99990 100024 99989 100026 99988 100028 99987 100030 99986 100032 99985 100034 99984 100036 99983 100038 99982 100040 99981 100042 99980 100044 999...

output:

49245747 395
100001 1
50001 1
100001 1
200003 2
100001 1
75001 1
200003 2
100002 1
100001 1
166669 2
100002 1
200005 2
100001 1
700011 8
200005 2
100003 1
100001 1
450008 5
100003 1
200007 2
100001 1
183337 2
200007 2
100004 1
100001 1
1300029 14
100004 1
200009 2
100001 1
1500037 16
200009 2
100005...

result:

ok correct!

Test #60:

score: 0
Accepted
time: 548ms
memory: 110780kb

input:

300000
1 100001 100002 100000 100004 99999 100006 99998 100008 99997 100010 99996 100012 99995 100014 99994 100016 99993 100018 99992 100020 99991 100022 99990 100024 99989 100026 99988 100028 99987 100030 99986 100032 99985 100034 99984 100036 99983 100038 99982 100040 99981 100042 99980 100044 999...

output:

49245747 395
100001 1
50001 1
100001 1
200003 2
100001 1
75001 1
200003 2
100002 1
100001 1
166669 2
100002 1
200005 2
100001 1
700011 8
200005 2
100003 1
100001 1
450008 5
100003 1
200007 2
100001 1
183337 2
200007 2
100004 1
100001 1
1300029 14
100004 1
200009 2
100001 1
1500037 16
200009 2
100005...

result:

ok correct!

Test #61:

score: 0
Accepted
time: 593ms
memory: 94792kb

input:

300000
1 1001 1002 1000 1004 999 1006 998 1008 997 1010 996 1012 995 1014 994 1016 993 1018 992 1020 991 1022 990 1024 989 1026 988 1028 987 1030 986 1032 985 1034 984 1036 983 1038 982 1040 981 1042 980 1044 979 1046 978 1048 977 1050 976 1052 975 1054 974 1056 973 1058 972 1060 971 1062 970 1064 9...

output:

11533623 9449
1001 1
501 1
1001 1
2003 2
1001 1
751 1
2003 2
1002 1
1001 1
1669 2
1002 1
2005 2
1001 1
7011 8
2005 2
1003 1
1001 1
4508 5
1003 1
2007 2
1001 1
1837 2
2007 2
1004 1
1001 1
13029 14
1004 1
2009 2
1001 1
15037 16
2009 2
1005 1
1001 1
947 1
1005 1
2011 2
1001 1
4764 5
2011 2
1006 1
1001 ...

result:

ok correct!

Test #62:

score: 0
Accepted
time: 604ms
memory: 94764kb

input:

300000
1 1001 1002 1000 1004 999 1006 998 1008 997 1010 996 1012 995 1014 994 1016 993 1018 992 1020 991 1022 990 1024 989 1026 988 1028 987 1030 986 1032 985 1034 984 1036 983 1038 982 1040 981 1042 980 1044 979 1046 978 1048 977 1050 976 1052 975 1054 974 1056 973 1058 972 1060 971 1062 970 1064 9...

output:

11533623 9449
1001 1
501 1
1001 1
2003 2
1001 1
751 1
2003 2
1002 1
1001 1
1669 2
1002 1
2005 2
1001 1
7011 8
2005 2
1003 1
1001 1
4508 5
1003 1
2007 2
1001 1
1837 2
2007 2
1004 1
1001 1
13029 14
1004 1
2009 2
1001 1
15037 16
2009 2
1005 1
1001 1
947 1
1005 1
2011 2
1001 1
4764 5
2011 2
1006 1
1001 ...

result:

ok correct!

Test #63:

score: 0
Accepted
time: 588ms
memory: 94816kb

input:

300000
1 1001 1002 1000 1004 999 1006 998 1008 997 1010 996 1012 995 1014 994 1016 993 1018 992 1020 991 1022 990 1024 989 1026 988 1028 987 1030 986 1032 985 1034 984 1036 983 1038 982 1040 981 1042 980 1044 979 1046 978 1048 977 1050 976 1052 975 1054 974 1056 973 1058 972 1060 971 1062 970 1064 9...

output:

11533623 9449
1001 1
501 1
1001 1
2003 2
1001 1
751 1
2003 2
1002 1
1001 1
1669 2
1002 1
2005 2
1001 1
7011 8
2005 2
1003 1
1001 1
4508 5
1003 1
2007 2
1001 1
1837 2
2007 2
1004 1
1001 1
13029 14
1004 1
2009 2
1001 1
15037 16
2009 2
1005 1
1001 1
947 1
1005 1
2011 2
1001 1
4764 5
2011 2
1006 1
1001 ...

result:

ok correct!

Test #64:

score: 0
Accepted
time: 505ms
memory: 120564kb

input:

300000
1 844157 2 835068 3 848006 4 817862 5 803825 6 848872 7 855386 8 850232 9 780342 10 732139 11 620566 12 836058 13 695606 14 747345 15 765537 16 741844 17 706070 18 727921 19 664681 20 643021 21 642040 22 853269 23 867053 24 892303 25 638769 26 810781 27 691069 28 704235 29 851779 30 683498 31...

output:

10268909828 26667
844159 2
422079 1
30805953405 79999
844160 3
835071 2
417535 1
30805126950 79997
835073 3
424005 1
848009 2
10268116591 26665
282671 1
817867 2
408933 1
61607045043 159986
817871 3
803831 2
401915 1
61605436009 159982
803836 3
848879 2
424439 1
20534655191 53326
848885 3
427697 1
8...

result:

ok correct!

Test #65:

score: 0
Accepted
time: 578ms
memory: 102828kb

input:

300000
1 7952802 2 4744145 3 4433516 4 9148724 5 4846440 6 9157226 7 9528994 8 5201017 9 7168705 10 9624838 11 7422985 12 4390578 13 8031723 14 6701810 15 7407503 16 4658307 17 4261657 18 7608455 19 7358171 20 9244470 21 9820877 22 7901109 23 5893826 24 4219694 25 4729626 26 4038139 27 9451152 28 85...

output:

1173347787211 293857
3976402 1
7952803 2
1173335785387 293853
2650935 1
2372074 1
4744147 2
1173321133292 293849
4744150 3
2216760 1
4433519 2
1173311222324 293845
1477841 1
9148729 2
4574364 1
1173294483055 293841
9148733 3
2423223 1
4846445 2
1173282076504 293837
4846451 3
9157233 2
4578616 1
1173...

result:

ok correct!

Test #66:

score: 0
Accepted
time: 981ms
memory: 123812kb

input:

300000
1 6804087 9384984 4971839 6138852 4533883 8223531 9529833 8990911 9996675 9823715 6323514 8621171 9761644 7275818 9581688 8029164 4231130 7708854 6359922 9008945 9293296 9905505 8082143 9515117 6451906 9209917 9316277 6122821 9638040 5696319 6711870 9672059 5685111 6571296 8752063 8216493 892...

output:

17220491 2
14465333 2
6663886 1
9105948 1
5697922 1
15331635 2
45409273 6
8364599 1
182923775 24
138865211 18
8877181 1
39296059 6
6691792 1
85880853 13
8669645 2
19883399 2
16842909 2
25332638 3
8241092 1
74772501 10
25612685 3
7541220 1
17080045 2
15715623 2
16734653 3
239455549 32
17815873 2
6426...

result:

ok correct!

Test #67:

score: 0
Accepted
time: 970ms
memory: 123780kb

input:

300000
1 7645939 9861235 6743634 5334145 7572680 8712765 9145390 9439296 4933189 9085164 9535652 4541032 6764883 7294010 9861872 8532836 7814632 9161032 8415340 7793153 8190230 9144525 7899994 9542680 8855699 9019170 3411933 7415379 5950893 5937918 7199339 7662167 9913008 6559045 8772793 8066627 829...

output:

9136921 1
8949686 1
30914739 4
7828812 1
23130940 3
17198401 2
45314236 5
7950725 1
7512196 1
8681664 1
13985235 2
49236981 7
9057058 1
36800111 4
18221541 2
426661669 52
22438124 3
6887278 1
36929039 5
9897694 1
38399587 5
170732935 21
9672017 1
315334105 39
37311791 5
8837328 1
16380695 2
7670157 ...

result:

ok correct!

Test #68:

score: 0
Accepted
time: 972ms
memory: 123260kb

input:

300000
1 9529644 9808294 8308480 9577549 8646036 9842966 9927854 7058385 8980675 9051375 9795963 8440625 9779608 8195385 9241212 9422237 9145803 9825460 9224081 9466227 8330579 9993601 7836548 8950515 9934446 9962819 9231590 9334034 9241575 9349451 9180367 4691276 9544949 9596726 8961446 8519085 965...

output:

23797141 3
8387045 1
18346299 2
8599371 1
46283431 6
25605721 3
18085899 2
147766750 17
19675657 2
778051364 91
9227884 1
9275348 1
9313274 1
17446053 2
7367573 1
15765521 2
9495302 1
8300763 1
29016325 3
14139203 2
8171180 1
31993119 4
16688009 2
8279302 1
24374944 3
18907869 2
8975502 1
8780811 1
...

result:

ok correct!

Test #69:

score: 0
Accepted
time: 882ms
memory: 121996kb

input:

300000
1 8804656 8938605 8374089 9969650 6802427 9737814 9420829 8110853 9330132 9729881 7937510 9132492 8588550 9199869 9844598 9869003 9868217 9320360 9584106 8103772 9491202 8806368 9588268 8871084 9229632 9501767 9346192 9770341 9060355 8500310 9448228 8575765 9495934 7364296 9612565 9437367 988...

output:

17318455 2
28311052 3
8702514 1
17279753 2
9225510 1
19799091 2
18267917 2
8254462 1
9524019 1
18727589 2
18949157 2
18597613 2
9670559 1
9614552 1
16857691 2
18978171 2
83665448 9
9545963 1
9100042 1
27219919 3
19400969 2
18745247 2
16965343 2
19212541 2
28466749 3
18159129 2
45372119 5
9311785 1
9...

result:

ok correct!

Test #70:

score: 0
Accepted
time: 1012ms
memory: 124012kb

input:

300000
1 7359512 3194225 7635139 8373441 9841034 7036967 6854807 3733621 9434135 8686555 7259899 9363992 9604391 6769764 6780609 7220159 6328078 9052690 4590099 8318290 3009746 5959221 2144076 9000945 7656389 9045859 7490208 7691865 8328678 8039897 6720485 5190578 5564661 8830714 8349654 9097949 776...

output:

15853085 2
38470097 6
28356551 4
11302231 2
13548155 2
13906367 2
131495589 19
69949604 9
11509107 2
7372048 1
13542591 2
19650659 2
7036169 1
13769183 2
7811658 1
14199135 2
45261768 7
5973297 1
308911550 43
6814431 1
38303555 6
7104037 1
6997661 1
34479102 5
8529399 1
20783201 3
20361291 4
1733869...

result:

ok correct!