QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#881280#10053. Post Officecmk66666 475ms206928kbC++2313.3kb2025-02-04 14:36:042025-02-04 14:36:04

Judging History

This is the latest submission verdict.

  • [2025-02-04 14:36:04]
  • Judged
  • Verdict: 66
  • Time: 475ms
  • Memory: 206928kb
  • [2025-02-04 14:36:04]
  • Submitted

answer

/*  _              _     _                                             _       __      __      __   
   / \     _   _  | |_  | |__     ___    _ __   _    ___   _ __ ___   | | __  / /_    / /_    / /_  
  / _ \   | | | | | __| | '_ \   / _ \  | '__| (_)  / __| | '_ ` _ \  | |/ / | '_ \  | '_ \  | '_ \ 
 / ___ \  | |_| | | |_  | | | | | (_) | | |     _  | (__  | | | | | | |   <  | (_) | | (_) | | (_) |
/_/   \_\  \__,_|  \__| |_| |_|  \___/  |_|    (_)  \___| |_| |_| |_| |_|\_\  \___/   \___/   \___/ 
[Created Time:       2025-02-02 21:45:16]
[Last Modified Time: 2025-02-04 14:35:56] */
#ifdef LOCAL
#include<bits/stdc++.h>
#include"debug.h"
#else
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
namespace FastIO
{
#define USE_FastIO
// ------------------------------
// #define DISABLE_MMAP
// ------------------------------
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifdef LOCAL
	inline void _chk_i() {}
	inline char _gc_nochk() { return getchar(); }
	inline char _gc() { return getchar(); }
	inline void _chk_o() {}
	inline void _pc_nochk(char c) { putchar(c); }
	inline void _pc(char c) { putchar(c); }
	template < int n > inline void _pnc_nochk(const char *c) { for ( int i = 0 ; i < n ; i++ ) putchar(c[i]); }
#else
#ifdef DISABLE_MMAP
	inline constexpr int _READ_SIZE = 1 << 18; inline static char _read_buffer[_READ_SIZE + 40], *_read_ptr = nullptr, *_read_ptr_end = nullptr; static inline bool _eof = false;
	inline void _chk_i() { if ( __builtin_expect(!_eof, true) && __builtin_expect(_read_ptr_end - _read_ptr < 40, false) ) { int sz = _read_ptr_end - _read_ptr; if ( sz ) memcpy(_read_buffer, _read_ptr, sz); char *beg = _read_buffer + sz; _read_ptr = _read_buffer, _read_ptr_end = beg + fread(beg, 1, _READ_SIZE, stdin); if ( __builtin_expect(_read_ptr_end != beg + _READ_SIZE, false) ) _eof = true, *_read_ptr_end = EOF; } }
	inline char _gc_nochk() { return __builtin_expect(_eof && _read_ptr == _read_ptr_end, false) ? EOF : *_read_ptr++; }
	inline char _gc() { _chk_i(); return _gc_nochk(); }
#else
#include<sys/mman.h>
#include<sys/stat.h>
	inline static char *_read_ptr = (char *)mmap(nullptr, [] { struct stat s; return fstat(0, &s), s.st_size; } (), 1, 2, 0, 0);
	inline void _chk_i() {}
	inline char _gc_nochk() { return *_read_ptr++; }
	inline char _gc() { return *_read_ptr++; }
#endif
	inline constexpr int _WRITE_SIZE = 1 << 18; inline static char _write_buffer[_WRITE_SIZE + 40], *_write_ptr = _write_buffer;
	inline void _chk_o() { if ( __builtin_expect(_write_ptr - _write_buffer > _WRITE_SIZE, false) ) fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout), _write_ptr = _write_buffer; }
	inline void _pc_nochk(char c) { *_write_ptr++ = c; }
	inline void _pc(char c) { *_write_ptr++ = c, _chk_o(); }
	template < int n > inline void _pnc_nochk(const char *c) { memcpy(_write_ptr, c, n), _write_ptr += n; }
	inline struct _auto_flush { inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); } } _auto_flush;
#endif
#define println println_ // don't use C++23 std::println
	template < class T > inline constexpr bool _is_signed = numeric_limits < T >::is_signed;
	template < class T > inline constexpr bool _is_unsigned = numeric_limits < T >::is_integer && !_is_signed < T >;
#if __SIZEOF_LONG__ == 64
	template <> inline constexpr bool _is_signed < __int128 > = true;
	template <> inline constexpr bool _is_unsigned < __uint128_t > = true;
#endif
	inline bool _isgraph(char c) { return c >= 33; }
	inline bool _isdigit(char c) { return 48 <= c && c <= 57; } // or faster, remove c <= 57
	constexpr struct _table {
#ifndef LOCAL
	int i[65536];
#endif
	char o[40000]; constexpr _table() :
#ifndef LOCAL
	i{},
#endif
	o{} {
#ifndef LOCAL
	for ( int x = 0 ; x < 65536 ; x++ ) i[x] = -1; for ( int x = 0 ; x <= 9 ; x++ ) for ( int y = 0 ; y <= 9 ; y++ ) i[x + y * 256 + 12336] = x * 10 + y;
#endif
	for ( int x = 0 ; x < 10000 ; x++ ) for ( int y = 3, z = x ; ~y ; y-- ) o[x * 4 + y] = z % 10 + 48, z /= 10; } } _table;
	template < class T, int digit > inline constexpr T _pw10 = 10 * _pw10 < T, digit - 1 >;
	template < class T > inline constexpr T _pw10 < T, 0 > = 1;
	inline void read(char &c) { do c = _gc(); while ( !_isgraph(c) ); }
	inline void read_cstr(char *s) { char c = _gc(); while ( !_isgraph(c) ) c = _gc(); while ( _isgraph(c) ) *s++ = c, c = _gc(); *s = 0; }
	inline void read(string &s) { char c = _gc(); s.clear(); while ( !_isgraph(c) ) c = _gc(); while ( _isgraph(c) ) s.push_back(c), c = _gc(); }
	template < class T, bool neg >
#ifndef LOCAL
	__attribute__((no_sanitize("undefined")))
#endif
	inline void _read_int_suf(T &x) { _chk_i(); char c; while
#ifndef LOCAL
	( ~_table.i[*reinterpret_cast < unsigned short *& >(_read_ptr)] ) if constexpr ( neg ) x = x * 100 - _table.i[*reinterpret_cast < unsigned short *& >(_read_ptr)++]; else x = x * 100 + _table.i[*reinterpret_cast < unsigned short *& >(_read_ptr)++]; if
#endif
	( _isdigit(c = _gc_nochk()) ) if constexpr ( neg ) x = x * 10 - ( c & 15 ); else x = x * 10 + ( c & 15 ); }
	template < class T, enable_if_t < _is_signed < T >, int > = 0 > inline void read(T &x) { char c; while ( !_isdigit(c = _gc()) ) if ( c == 45 ) { _read_int_suf < T, true >(x = -( _gc_nochk() & 15 )); return; } _read_int_suf < T, false >(x = c & 15); }
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 > inline void read(T &x) { char c; while ( !_isdigit(c = _gc()) ); _read_int_suf < T, false >(x = c & 15); }
	inline void write(bool x) { _pc(x | 48); }
	inline void write(char c) { _pc(c); }
	inline void write_cstr(const char *s) { while ( *s ) _pc(*s++); }
	inline void write(const string &s) { for ( char c : s ) _pc(c); }
	template < class T, bool neg, int digit > inline void _write_int_suf(T x) { if constexpr ( digit == 4 ) _pnc_nochk < 4 >(_table.o + ( neg ? -x : x ) * 4); else _write_int_suf < T, neg, digit / 2 >(x / _pw10 < T, digit / 2 >), _write_int_suf < T, neg, digit / 2 >(x % _pw10 < T, digit / 2 >); }
	template < class T, bool neg, int digit > inline void _write_int_pre(T x) { if constexpr ( digit <= 4 ) if ( digit >= 3 && ( neg ? x <= -100 : x >= 100 ) ) if ( digit >= 4 && ( neg ? x <= -1000 : x >= 1000 ) ) _pnc_nochk < 4 >(_table.o + ( neg ? -x : x ) * 4); else _pnc_nochk < 3 >(_table.o + ( neg ? -x : x ) * 4 + 1); else if ( digit >= 2 && ( neg ? x <= -10 : x >= 10 ) ) _pnc_nochk < 2 >(_table.o + ( neg ? -x : x ) * 4 + 2); else _pc_nochk(( neg ? -x : x ) | 48); else { constexpr int cur = 1 << __lg(digit - 1); if ( neg ? x <= -_pw10 < T, cur > : x >= _pw10 < T, cur > ) _write_int_pre < T, neg, digit - cur >(x / _pw10 < T, cur >), _write_int_suf < T, neg, cur >(x % _pw10 < T, cur >); else _write_int_pre < T, neg, cur >(x); } }
	template < class T, enable_if_t < _is_signed < T >, int > = 0 > inline void write(T x) { if ( x >= 0 ) _write_int_pre < T, false, numeric_limits < T >::digits10 + 1 >(x); else _pc_nochk(45), _write_int_pre < T, true, numeric_limits < T >::digits10 + 1 >(x); _chk_o(); }
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 > inline void write(T x) { _write_int_pre < T, false, numeric_limits < T >::digits10 + 1 >(x), _chk_o(); }
	template < size_t N, class ...T > inline void _read_tuple(tuple < T... > &x) { read(get < N >(x)); if constexpr ( N + 1 != sizeof...(T) ) _read_tuple < N + 1, T... >(x); }
	template < size_t N, class ...T > inline void _write_tuple(const tuple < T... > &x) { write(get < N >(x)); if constexpr ( N + 1 != sizeof...(T) ) _pc(32), _write_tuple < N + 1, T... >(x); }
	template < class ...T > inline void read(tuple < T... > &x) { _read_tuple < 0, T... >(x); }
	template < class ...T > inline void write(const tuple < T... > &x) { _write_tuple < 0, T... >(x); }
	template < class T1, class T2 > inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
	template < class T1, class T2 > inline void write(const pair < T1, T2 > &x) { write(x.first), _pc(32), write(x.second); }
	template < class T > inline auto read(T &x) -> decltype(x.read(), void()) { x.read(); }
	template < class T > inline auto write(const T &x) -> decltype(x.write(), void()) { x.write(); }
	template < class T1, class ...T2 > inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
	template < class ...T > inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
	template < class T1, class ...T2 > inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
	template < class ...T > inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
	template < class T > inline void print(const T &x) { write(x); }
	inline void print_cstr(const char *x) { write_cstr(x); }
	template < class T1, class ...T2 > inline void print(const T1 &x, const T2 &...y) { write(x), _pc(32), print(y...); }
	template < class ...T > inline void print_cstr(const char *x, const T *...y) { write_cstr(x), _pc(32), print_cstr(y...); }
	inline void println() { _pc(10); }
	inline void println_cstr() { _pc(10); }
	template < class ...T > inline void println(const T &...x) { print(x...), _pc(10); }
	template < class ...T > inline void println_cstr(const T *...x) { print_cstr(x...), _pc(10); }
}	using FastIO::read, FastIO::read_cstr, FastIO::write, FastIO::write_cstr, FastIO::println, FastIO::println_cstr;
constexpr int inf = numeric_limits < int >::max() >> 1;
struct info
{
	int f, g;
	inline info() {}
	inline info(int x) : f(-x), g(0) {}
	inline info(int f, int g) : f(f), g(g) {}
	inline info operator+(const info &o)const { return info(f + o.f, max(g + o.f, o.g)); }
	inline int operator()(int x)const { return max(x + f, g); }
};
namespace ST
{
	struct node
	{
		int lc, rc; info v;
	}	t[16000009]; int cnt;
	inline int &lc(int p) { return t[p].lc; }
	inline int &rc(int p) { return t[p].rc; }
	inline int md(int l, int r) { return ( l + r ) >> 1; }
	inline void pu(int p, int l, int r)
	{
		t[p].v = ( lc(p) ? t[lc(p)].v : info(md(l, r) - l + 1) )
			   + ( rc(p) ? t[rc(p)].v : info(r - md(l, r)) );
	}
	inline void add(int &p, int l, int r, int pos, int v)
	{
		if ( !p ) p = ++cnt, t[p].v = info(r - l + 1);
		if ( l == r ) { t[p].v.f += v; return; }
		pos <= md(l, r) ? add(lc(p), l, md(l, r), pos, v) : add(rc(p), md(l, r) + 1, r, pos, v), pu(p, l, r);
	}
	inline int fnd(int p, int l, int r)
	{
		if ( !p || -t[p].v.f == r - l + 1 ) return -1;
		if ( l == r ) return l;
		int z = fnd(rc(p), md(l, r) + 1, r); return ~z ? z : fnd(lc(p), l, md(l, r));
	}
	inline info qry(int p, int l, int r, int lp, int rp)
	{
		if ( l > rp || r < lp ) return info(0, 0);
		if ( lp <= l && r <= rp ) return p ? t[p].v : info(r - l + 1);
		return qry(lc(p), l, md(l, r), lp, rp) + qry(rc(p), md(l, r) + 1, r, lp, rp);
	}
	inline void mrg(int &p, int q, int l, int r)
	{
		if ( !q ) return; if ( !p ) { p = q; return; }
		if ( l == r ) { t[p].v.f += t[q].v.f + 1; return; }
		mrg(lc(p), lc(q), l, md(l, r)), mrg(rc(p), rc(q), md(l, r) + 1, r), pu(p, l, r);
	}
}
int n, m, o, p[200009], deg[200009], bel[200009], rt[200009], dep[200009], tot, cycl[200009], ord[200009];
int dfn[200009], nfd[200009], cnt, a[200009], b[200009], tdep[400009], trt[400009], ans;
queue < int > que; vector < int > rts, tr[200009], g[400009], del[400009];
inline void dfs(int u)
{
	bel[u] = bel[p[u]], rt[u] = rt[p[u]], dep[u] = dep[p[u]] + 1, dfn[u] = ++cnt;
	for ( int i : tr[u] ) dfs(i);
	nfd[u] = cnt;
}
inline bool anc(int u, int v) { return dfn[u] <= dfn[v] && dfn[v] <= nfd[u]; }
inline void dfs1(int u, int fa = 0) { tdep[u] = tdep[fa] + 1; for ( int i : g[u] ) dfs1(i, u); }
inline void ins(int u, int v) { ST::add(trt[u], 1, n + n, tdep[u], 1), del[v].push_back(tdep[u]); }
inline void dfs2(int u)
{
	for ( int i : g[u] ) dfs2(i), ST::mrg(trt[u], trt[i], 1, n + n);
	for ( int i : del[u] ) ST::add(trt[u], 1, n + n, i, -1);
	o = ST::fnd(trt[u], 1, n + n);
	if ( ~o ) ans = max(ans, ST::qry(trt[u], 1, n + n, tdep[u], o)(0) + o - tdep[u] + 1);
}
int main()
{
	read(n);
	For(i, 1, n) read(p[i]), deg[p[i]]++;
	For(i, 1, n) if ( !deg[i] ) que.push(i);
	for ( int u ; que.size() ; )
	{
		u = que.front(), que.pop(), tr[p[u]].push_back(u);
		g[p[u]].push_back(u), g[p[u] + n].push_back(u + n);
		if ( !--deg[p[u]] ) que.push(p[u]);
	}
	For(i, 1, n) if ( deg[i] && !bel[i] )
	{
		o = i, tot++;
		do
		{
			bel[o] = tot, rt[o] = o, ord[o] = ++cycl[tot];
			if ( p[o] == i ) g[i + n].push_back(o), rts.push_back(o + n);
			else g[p[o]].push_back(o), g[p[o] + n].push_back(o + n);
		}
		while ( ( o = p[o] ) != i );
	}
	For(i, 1, n) if ( deg[i] ) { dfn[i] = ++cnt; for ( int j : tr[i] ) dfs(j); nfd[i] = cnt; }
	for ( int i : rts ) dfs1(i);
	read(m);
	For(i, 1, m)
	{
		read(a[i], b[i]);
		if ( bel[a[i]] != bel[b[i]] ) return println(-1), 0;
		if ( rt[a[i]] == rt[b[i]] )
		{
			if ( !anc(b[i], a[i]) ) return println(-1), 0;
			ins(a[i], b[i]), ins(a[i] + n, b[i] + n);
		}
		else
		{
			if ( dep[b[i]] ) return println(-1), 0;
			if ( ord[rt[a[i]]] < ord[b[i]] ) ins(a[i], b[i]), ins(a[i] + n, b[i] + n);
			else ins(a[i], b[i] + n);
		}
	}
	for ( int i : rts ) dfs2(i);
	return println(ans), 0;
}
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏

詳細信息

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 3ms
memory: 10980kb

input:

3000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

1119

result:

ok single line: '1119'

Test #2:

score: 3
Accepted
time: 3ms
memory: 10912kb

input:

3000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

774

result:

ok single line: '774'

Test #3:

score: 3
Accepted
time: 3ms
memory: 10444kb

input:

3000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

-1

result:

ok single line: '-1'

Test #4:

score: 3
Accepted
time: 2ms
memory: 10316kb

input:

3000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

-1

result:

ok single line: '-1'

Test #5:

score: 3
Accepted
time: 1ms
memory: 12200kb

input:

3000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

-1

result:

ok single line: '-1'

Test #6:

score: 3
Accepted
time: 2ms
memory: 14468kb

input:

3000
1 1 1 2 4 4 5 7 7 5 4 11 6 7 6 12 5 6 9 14 16 11 18 1 18 11 16 8 6 28 10 6 30 33 30 1 11 21 36 21 31 35 14 40 26 35 26 24 21 20 3 15 43 36 20 37 33 14 14 46 12 1 38 1 29 57 10 24 4 34 67 29 37 37 73 47 34 32 29 65 48 21 39 24 75 51 75 85 11 27 69 83 32 41 67 32 62 42 10 73 87 2 88 29 81 71 41 2...

output:

-1

result:

ok single line: '-1'

Test #7:

score: 3
Accepted
time: 2ms
memory: 10144kb

input:

3000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

-1

result:

ok single line: '-1'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 9
Accepted
time: 1ms
memory: 12016kb

input:

5
2 1 1 3 1
5
1 2
4 1
5 1
3 1
4 1

output:

3

result:

ok single line: '3'

Test #9:

score: 9
Accepted
time: 2ms
memory: 12020kb

input:

5
2 1 2 3 3
5
3 2
5 2
5 1
4 2
2 1

output:

4

result:

ok single line: '4'

Test #10:

score: 9
Accepted
time: 1ms
memory: 9932kb

input:

5
2 1 1 2 4
5
5 1
4 1
3 2
5 2
4 2

output:

4

result:

ok single line: '4'

Test #11:

score: 9
Accepted
time: 1ms
memory: 12020kb

input:

5
2 1 1 1 1
5
1 2
3 1
2 1
4 2
2 1

output:

2

result:

ok single line: '2'

Test #12:

score: 9
Accepted
time: 0ms
memory: 14048kb

input:

5
2 1 1 2 4
5
3 1
5 2
1 2
3 1
4 2

output:

2

result:

ok single line: '2'

Test #13:

score: 9
Accepted
time: 0ms
memory: 12016kb

input:

5
2 1 1 1 2
5
5 2
3 2
3 1
5 2
2 1

output:

2

result:

ok single line: '2'

Test #14:

score: 9
Accepted
time: 2ms
memory: 9968kb

input:

5
2 1 2 2 4
5
2 1
5 2
3 2
5 1
2 1

output:

3

result:

ok single line: '3'

Test #15:

score: 9
Accepted
time: 1ms
memory: 9932kb

input:

5
2 1 2 3 4
5
4 1
5 2
5 2
3 1
1 2

output:

4

result:

ok single line: '4'

Test #16:

score: 9
Accepted
time: 2ms
memory: 12016kb

input:

10
2 3 4 5 1 1 1 4 6 2
10
4 2
1 4
6 2
3 1
4 3
10 4
7 3
5 3
6 2
7 1

output:

7

result:

ok single line: '7'

Test #17:

score: 9
Accepted
time: 2ms
memory: 12020kb

input:

10
2 3 4 5 1 2 6 5 8 1
10
3 4
10 2
4 1
6 2
10 4
4 1
7 1
5 1
10 3
1 3

output:

6

result:

ok single line: '6'

Test #18:

score: 9
Accepted
time: 1ms
memory: 14000kb

input:

10
2 3 4 5 1 5 3 5 5 8
10
5 3
10 3
8 5
9 4
2 4
4 3
3 4
1 4
10 4
6 1

output:

7

result:

ok single line: '7'

Test #19:

score: 9
Accepted
time: 2ms
memory: 9936kb

input:

10
2 3 4 5 1 2 5 6 4 7
10
7 5
10 1
3 2
1 5
3 1
10 3
4 1
3 5
1 5
7 4

output:

7

result:

ok single line: '7'

Test #20:

score: 9
Accepted
time: 1ms
memory: 13920kb

input:

10
2 3 4 5 1 4 3 5 2 5
10
7 4
5 2
10 5
6 5
6 5
8 5
8 3
3 4
4 2
9 5

output:

4

result:

ok single line: '4'

Test #21:

score: 0
Wrong Answer
time: 5ms
memory: 15208kb

input:

3000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

output:

1507

result:

wrong answer 1st lines differ - expected: '1563', found: '1507'

Subtask #3:

score: 13
Accepted

Test #34:

score: 13
Accepted
time: 6ms
memory: 15700kb

input:

2
1 1
200000
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1...

output:

200000

result:

ok single line: '200000'

Test #35:

score: 13
Accepted
time: 415ms
memory: 170008kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

200000

result:

ok single line: '200000'

Test #36:

score: 13
Accepted
time: 303ms
memory: 119104kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

200008

result:

ok single line: '200008'

Test #37:

score: 13
Accepted
time: 5ms
memory: 11232kb

input:

3000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

5998

result:

ok single line: '5998'

Test #38:

score: 13
Accepted
time: 163ms
memory: 95340kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

399998

result:

ok single line: '399998'

Test #39:

score: 13
Accepted
time: 5ms
memory: 13516kb

input:

3000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

3000

result:

ok single line: '3000'

Test #40:

score: 13
Accepted
time: 178ms
memory: 99208kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

200000

result:

ok single line: '200000'

Subtask #4:

score: 25
Accepted

Test #41:

score: 25
Accepted
time: 463ms
memory: 174772kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

199401

result:

ok single line: '199401'

Test #42:

score: 25
Accepted
time: 475ms
memory: 175404kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

199604

result:

ok single line: '199604'

Test #43:

score: 25
Accepted
time: 2ms
memory: 10704kb

input:

3000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

-1

result:

ok single line: '-1'

Test #44:

score: 25
Accepted
time: 137ms
memory: 124568kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

-1

result:

ok single line: '-1'

Test #45:

score: 25
Accepted
time: 6ms
memory: 11464kb

input:

3000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

1496

result:

ok single line: '1496'

Test #46:

score: 25
Accepted
time: 439ms
memory: 166692kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

99857

result:

ok single line: '99857'

Test #47:

score: 25
Accepted
time: 4ms
memory: 13380kb

input:

3000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

5964

result:

ok single line: '5964'

Test #48:

score: 25
Accepted
time: 172ms
memory: 103612kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

398029

result:

ok single line: '398029'

Test #49:

score: 25
Accepted
time: 6ms
memory: 13516kb

input:

3000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

2490

result:

ok single line: '2490'

Test #50:

score: 25
Accepted
time: 447ms
memory: 190152kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

195055

result:

ok single line: '195055'

Subtask #5:

score: 0
Wrong Answer

Test #51:

score: 11
Accepted
time: 7ms
memory: 15232kb

input:

2
2 1
200000
2 1
2 1
1 2
2 1
1 2
1 2
2 1
1 2
1 2
2 1
2 1
1 2
2 1
2 1
1 2
1 2
2 1
1 2
1 2
2 1
2 1
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
2 1
2 1
2 1
1 2
2 1
1 2
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
2 1
1 2
1 2
1 2
2 1
1 2
1 2
1 2
1 2
2 1
2 1
2 1
1 2
1 2
1 2
2 1
2 1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
2 1
1 2
1 2
2 1
2 1...

output:

100031

result:

ok single line: '100031'

Test #52:

score: 11
Accepted
time: 397ms
memory: 206928kb

input:

200000
200000 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

199999

result:

ok single line: '199999'

Test #53:

score: 11
Accepted
time: 377ms
memory: 206620kb

input:

200000
200000 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

199999

result:

ok single line: '199999'

Test #54:

score: 11
Accepted
time: 5ms
memory: 13900kb

input:

3000
3000 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

1499

result:

ok single line: '1499'

Test #55:

score: 11
Accepted
time: 395ms
memory: 197896kb

input:

200000
200000 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

99898

result:

ok single line: '99898'

Test #56:

score: 0
Wrong Answer
time: 4ms
memory: 16036kb

input:

3000
3000 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

3064

result:

wrong answer 1st lines differ - expected: '3098', found: '3064'

Subtask #6:

score: 25
Accepted

Test #60:

score: 25
Accepted
time: 346ms
memory: 120440kb

input:

200000
1 1 1 3 3 2 5 3 4 6 9 3 3 9 14 13 4 2 18 9 3 11 20 13 7 13 14 6 13 2 22 14 5 9 19 7 28 22 10 37 37 26 15 39 18 31 18 19 22 6 4 22 29 30 43 38 33 39 19 10 14 25 35 5 3 50 34 13 60 44 31 47 67 27 52 26 48 30 18 63 76 80 49 16 39 16 59 77 60 26 84 50 54 36 75 77 72 77 1 45 13 20 86 19 56 9 47 82...

output:

119708

result:

ok single line: '119708'

Test #61:

score: 25
Accepted
time: 337ms
memory: 121576kb

input:

200000
1 1 1 1 3 4 5 2 3 3 7 11 6 4 7 3 1 17 3 1 3 2 22 16 9 20 16 26 1 17 29 24 17 24 1 26 30 14 37 27 21 14 29 36 5 11 46 47 7 8 39 23 16 52 38 34 19 10 29 50 32 8 19 29 28 61 12 26 39 48 44 56 37 43 32 37 28 23 56 49 33 60 77 12 66 37 17 85 42 52 75 68 91 4 71 68 91 39 86 97 94 48 1 101 97 72 60 ...

output:

80568

result:

ok single line: '80568'

Test #62:

score: 25
Accepted
time: 2ms
memory: 14568kb

input:

3000
1 1 1 3 2 2 3 6 4 5 2 7 5 2 10 9 9 15 8 14 20 14 21 19 1 13 8 18 17 15 22 15 19 31 26 10 3 37 36 39 21 30 2 14 19 11 31 40 4 31 2 43 18 2 32 28 50 26 40 53 17 19 31 31 37 52 19 41 66 35 26 26 28 33 19 71 61 31 54 16 11 81 35 17 33 58 30 48 18 77 90 4 45 11 31 74 10 14 10 66 1 27 57 81 80 14 86 ...

output:

-1

result:

ok single line: '-1'

Test #63:

score: 25
Accepted
time: 102ms
memory: 90816kb

input:

200000
1 1 2 2 4 3 1 4 2 9 4 7 10 5 14 12 12 8 5 3 15 11 22 10 7 18 1 8 2 1 29 21 25 8 19 14 15 28 22 30 35 21 14 5 5 40 17 46 25 31 23 36 46 5 35 10 22 49 30 7 30 56 17 25 23 41 18 4 46 23 26 35 40 36 44 48 4 43 45 61 6 64 18 42 5 44 51 35 49 87 49 73 76 49 73 82 21 84 70 93 14 25 33 23 22 19 85 31...

output:

-1

result:

ok single line: '-1'

Test #64:

score: 25
Accepted
time: 3ms
memory: 14952kb

input:

3000
1 1 2 3 3 5 3 6 7 6 9 11 9 10 12 15 16 16 15 16 20 21 22 22 22 23 23 27 28 29 29 30 31 30 33 33 35 37 36 36 39 41 41 40 42 45 44 46 45 46 50 51 50 50 53 52 54 57 58 56 60 58 60 63 63 62 66 67 67 67 68 69 71 71 71 74 73 77 76 76 78 78 79 81 81 85 85 87 85 88 87 89 92 92 92 94 93 96 98 99 97 100 ...

output:

7

result:

ok single line: '7'

Test #65:

score: 25
Accepted
time: 3ms
memory: 12256kb

input:

3000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

3000

result:

ok single line: '3000'

Test #66:

score: 25
Accepted
time: 410ms
memory: 143280kb

input:

200000
1 1 1 2 1 3 4 7 5 7 10 8 10 13 14 14 13 14 18 17 18 19 20 23 23 23 24 27 25 28 27 30 31 33 33 34 33 37 38 37 40 38 41 40 42 44 46 47 48 46 49 51 51 51 53 52 54 54 58 56 59 59 62 61 64 63 66 65 65 69 69 70 69 71 72 75 75 75 76 78 77 80 82 82 81 83 84 87 85 86 90 91 90 90 91 93 95 96 96 99 97 9...

output:

9

result:

ok single line: '9'

Test #67:

score: 25
Accepted
time: 402ms
memory: 138952kb

input:

200000
1 1 2 3 4 2 6 6 4 7 10 7 10 10 10 11 14 15 17 19 20 20 22 20 23 25 22 23 25 27 30 27 28 29 31 35 34 37 37 35 37 39 39 42 42 43 45 46 45 45 48 47 48 51 54 54 52 55 56 55 58 61 61 63 62 65 62 63 65 68 69 67 70 71 72 71 76 74 75 75 76 79 82 79 81 81 82 83 87 89 88 89 89 91 92 94 93 95 95 99 100 ...

output:

10

result:

ok single line: '10'

Test #68:

score: 25
Accepted
time: 403ms
memory: 134744kb

input:

200000
1 1 1 3 2 2 3 6 4 3 6 9 5 7 14 9 9 10 12 14 16 21 21 19 17 20 24 21 21 29 26 28 27 29 32 32 31 30 34 38 37 41 42 36 43 42 41 42 44 48 48 51 50 46 50 54 50 57 52 55 53 54 55 58 61 61 63 63 66 67 66 69 68 69 73 72 73 76 76 79 75 79 79 78 77 85 86 80 82 82 88 89 85 90 93 93 90 92 92 96 93 95 95 ...

output:

9

result:

ok single line: '9'

Test #69:

score: 25
Accepted
time: 387ms
memory: 128396kb

input:

200000
1 1 2 2 4 3 1 4 2 9 4 7 10 5 14 5 14 16 9 12 9 18 18 13 17 17 25 16 16 17 25 19 29 25 27 35 23 36 26 36 33 36 42 42 41 37 35 45 39 38 45 50 52 41 41 54 50 44 46 47 58 55 61 60 53 53 60 58 68 64 68 65 62 70 64 64 72 71 65 68 72 78 72 75 75 79 83 86 75 81 83 87 90 84 93 87 83 89 98 88 100 93 91...

output:

10

result:

ok single line: '10'

Test #70:

score: 25
Accepted
time: 73ms
memory: 22520kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

200000

result:

ok single line: '200000'

Test #71:

score: 25
Accepted
time: 312ms
memory: 121376kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

11

result:

ok single line: '11'

Test #72:

score: 25
Accepted
time: 311ms
memory: 120428kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

10

result:

ok single line: '10'

Test #73:

score: 25
Accepted
time: 276ms
memory: 99880kb

input:

200000
1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 ...

output:

11

result:

ok single line: '11'

Test #74:

score: 25
Accepted
time: 4ms
memory: 14988kb

input:

3000
1 1 1 3 4 4 5 6 8 9 10 11 12 13 14 15 15 17 17 18 20 20 22 23 23 24 25 26 28 28 30 30 32 32 34 35 35 36 38 38 40 41 42 43 43 45 45 47 48 49 49 50 52 52 53 54 56 57 57 59 60 60 62 63 63 65 66 67 68 69 69 70 71 73 74 74 76 77 78 79 79 81 81 82 83 84 85 87 88 88 89 90 92 92 94 94 95 96 98 98 100 1...

output:

2040

result:

ok single line: '2040'

Test #75:

score: 25
Accepted
time: 412ms
memory: 160888kb

input:

200000
1 1 1 3 4 5 5 7 8 8 9 11 11 13 14 14 16 16 17 18 20 21 21 22 24 25 26 26 28 28 29 31 31 33 34 34 35 37 37 39 40 40 42 42 43 45 45 47 47 48 49 50 52 53 54 55 56 56 58 59 59 61 62 63 63 65 66 66 68 68 69 70 71 73 73 75 76 77 77 79 79 81 81 83 83 85 86 87 87 89 90 91 92 92 93 94 96 96 97 98 100 ...

output:

134559

result:

ok single line: '134559'

Test #76:

score: 25
Accepted
time: 420ms
memory: 162176kb

input:

200000
1 1 2 2 3 4 5 6 7 9 10 11 12 13 14 14 15 17 18 19 19 21 22 23 23 24 25 27 28 29 29 31 32 33 33 35 35 36 38 39 40 41 42 42 44 44 45 47 48 49 50 51 51 53 53 54 56 57 58 59 60 60 61 63 64 65 66 66 67 68 69 71 72 72 73 74 76 77 78 79 80 81 82 83 84 84 85 87 88 89 90 90 91 93 94 94 95 96 97 98 100...

output:

134537

result:

ok single line: '134537'

Test #77:

score: 25
Accepted
time: 424ms
memory: 161788kb

input:

200000
1 1 1 2 4 4 5 6 7 9 10 10 12 13 14 14 15 17 17 18 20 21 22 23 24 25 26 26 28 29 30 30 32 32 34 35 35 37 38 39 39 40 42 43 44 45 46 47 47 49 49 51 51 52 54 55 55 57 58 58 60 60 62 63 63 64 66 67 68 69 69 71 71 72 73 74 76 76 77 79 80 80 81 83 83 84 85 87 87 88 89 91 92 92 93 95 96 96 98 99 99 ...

output:

134994

result:

ok single line: '134994'

Test #78:

score: 25
Accepted
time: 3ms
memory: 10832kb

input:

3000
1 1 2 3 4 2 6 6 4 7 10 7 10 10 10 11 14 15 17 19 20 20 22 20 23 25 22 23 25 27 30 27 28 29 31 35 34 37 37 35 37 39 39 42 42 43 45 46 45 45 48 47 48 51 54 54 52 55 56 55 58 61 61 63 62 65 62 63 65 68 69 67 70 71 72 71 76 74 75 75 76 79 82 79 81 81 82 83 87 89 88 89 89 91 92 94 93 95 95 99 100 10...

output:

3988

result:

ok single line: '3988'

Test #79:

score: 25
Accepted
time: 3ms
memory: 10132kb

input:

3000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

48

result:

ok single line: '48'

Test #80:

score: 25
Accepted
time: 137ms
memory: 63744kb

input:

200000
1 1 2 2 4 3 5 4 6 7 8 9 10 12 14 13 16 16 17 16 19 18 20 23 23 25 23 26 26 27 27 29 29 33 33 35 35 34 38 36 39 38 42 40 41 43 43 45 45 46 49 50 50 51 53 52 54 54 58 59 58 59 61 62 63 65 64 64 66 68 70 71 72 70 72 74 76 75 77 76 78 80 80 83 81 83 85 86 85 87 87 91 92 90 93 93 93 97 98 96 98 99...

output:

280167

result:

ok single line: '280167'

Test #81:

score: 25
Accepted
time: 137ms
memory: 61556kb

input:

200000
1 1 1 1 1 1 6 5 8 7 8 7 11 10 11 12 16 13 17 17 18 18 18 20 24 22 22 27 25 29 28 29 29 31 30 34 36 37 37 36 37 41 42 42 43 41 44 46 48 45 47 47 49 53 54 54 52 57 57 57 60 57 60 59 64 64 62 66 67 65 70 69 70 71 70 71 74 74 75 77 78 80 81 83 81 85 86 85 87 89 86 90 91 90 92 94 92 93 98 99 100 9...

output:

266784

result:

ok single line: '266784'

Test #82:

score: 25
Accepted
time: 127ms
memory: 56008kb

input:

200000
1 1 1 1 4 4 1 2 4 9 5 11 9 8 9 15 13 12 17 12 18 19 18 22 21 18 21 27 23 23 23 29 28 29 27 28 35 37 32 37 33 38 41 41 39 41 39 47 47 46 43 44 51 49 49 53 52 55 57 58 58 61 60 62 64 58 65 67 68 66 65 66 71 71 71 72 74 74 77 73 76 75 75 81 77 83 86 84 85 89 86 91 90 88 87 94 95 93 94 94 96 99 1...

output:

244467

result:

ok single line: '244467'

Test #83:

score: 25
Accepted
time: 120ms
memory: 51636kb

input:

200000
1 1 1 1 2 3 1 1 7 7 10 9 4 4 3 14 12 16 8 18 18 11 18 18 21 13 22 18 25 23 26 22 29 31 31 29 23 28 37 33 31 36 32 41 40 33 44 34 39 38 50 44 41 48 47 52 44 50 53 50 47 49 52 54 53 63 63 59 55 60 67 62 62 69 66 62 72 70 66 78 76 80 77 77 74 80 84 74 75 81 81 88 83 88 82 86 84 96 90 96 88 92 10...

output:

226657

result:

ok single line: '226657'

Test #84:

score: 25
Accepted
time: 73ms
memory: 21796kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2102

result:

ok single line: '2102'

Test #85:

score: 25
Accepted
time: 130ms
memory: 60564kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

299899

result:

ok single line: '299899'

Test #86:

score: 25
Accepted
time: 121ms
memory: 59008kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

299999

result:

ok single line: '299999'

Test #87:

score: 25
Accepted
time: 87ms
memory: 36828kb

input:

200000
1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 ...

output:

200016

result:

ok single line: '200016'

Test #88:

score: 25
Accepted
time: 5ms
memory: 10952kb

input:

3000
1 1 1 2 1 5 3 7 4 9 10 10 8 13 11 13 14 15 14 17 20 17 19 20 20 25 26 26 26 27 27 30 32 29 31 33 33 34 37 36 36 41 40 43 42 42 42 47 48 48 47 47 51 51 52 55 55 55 58 58 57 57 58 59 64 63 66 66 68 68 68 71 68 71 71 71 75 75 75 76 76 77 79 79 81 81 83 86 85 85 87 89 90 90 93 93 96 94 94 96 99 98 ...

output:

12

result:

ok single line: '12'

Test #89:

score: 25
Accepted
time: 450ms
memory: 157132kb

input:

200000
1 1 2 3 4 3 4 4 5 9 8 8 11 13 13 12 16 17 18 17 19 21 19 22 21 24 23 24 25 27 29 31 29 31 32 32 34 34 36 38 39 39 39 42 43 42 45 46 48 48 48 49 50 52 52 53 54 54 58 56 60 59 62 60 61 62 64 66 68 68 68 68 72 73 72 75 76 77 78 78 77 80 79 81 81 84 84 85 86 86 89 91 91 93 91 95 94 94 96 97 98 10...

output:

20

result:

ok single line: '20'

Test #90:

score: 25
Accepted
time: 439ms
memory: 152852kb

input:

200000
1 1 1 3 2 2 4 5 7 8 7 10 8 10 10 14 14 17 17 17 20 18 19 21 24 23 22 26 25 29 27 30 30 33 31 35 34 34 35 39 36 41 42 40 40 41 42 44 47 47 47 49 48 53 50 53 53 53 58 59 57 58 60 60 63 62 66 64 66 66 66 67 71 71 72 71 75 77 75 76 76 81 82 82 82 83 86 84 87 89 90 89 89 89 94 94 96 94 94 99 96 98...

output:

18

result:

ok single line: '18'

Test #91:

score: 25
Accepted
time: 432ms
memory: 148892kb

input:

200000
1 1 2 2 4 3 1 4 2 3 4 9 6 8 14 13 12 12 17 12 19 18 20 19 23 21 19 22 22 23 23 29 25 29 33 35 31 34 34 36 35 38 42 36 37 39 43 41 41 42 45 46 46 51 49 52 54 54 58 55 54 55 57 58 63 61 60 64 62 68 70 71 72 66 68 70 72 75 73 76 78 80 76 83 77 83 81 86 81 87 87 91 92 86 93 93 93 93 94 96 94 95 9...

output:

21

result:

ok single line: '21'

Test #92:

score: 25
Accepted
time: 409ms
memory: 145280kb

input:

200000
1 1 1 1 1 1 5 7 4 9 8 10 11 3 14 9 11 14 12 19 11 18 11 13 18 21 22 21 18 25 25 28 27 28 26 28 33 25 31 29 37 36 37 31 39 34 43 40 46 43 50 41 51 51 50 46 46 44 48 59 52 55 49 51 52 54 60 54 55 63 64 70 60 63 64 63 71 71 70 76 74 73 80 70 75 81 78 74 85 84 89 89 92 91 89 82 84 89 94 94 98 91 ...

output:

19

result:

ok single line: '19'

Test #93:

score: 25
Accepted
time: 211ms
memory: 101388kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

8

result:

ok single line: '8'

Test #94:

score: 25
Accepted
time: 327ms
memory: 147640kb

input:

200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

16

result:

ok single line: '16'

Test #95:

score: 25
Accepted
time: 303ms
memory: 146624kb

input:

200000
1 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

50167

result:

ok single line: '50167'

Test #96:

score: 25
Accepted
time: 311ms
memory: 124592kb

input:

200000
1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 ...

output:

21

result:

ok single line: '21'

Subtask #7:

score: 0
Wrong Answer

Test #97:

score: 0
Wrong Answer
time: 412ms
memory: 157056kb

input:

200000
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

100391

result:

wrong answer 1st lines differ - expected: '100667', found: '100391'