Submission #792798

# Submission time Handle Problem Language Result Execution time Memory
792798 2023-07-25T08:54:11 Z 박영우(#10055) Real Mountains (CCO23_day1problem2) C++17
25 / 25
4447 ms 163060 KB
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
/*
 * Author : jinhan814
 * Date : 2021-05-06
 * Source : https://blog.naver.com/jinhan814/222266396476
 * Description : FastIO implementation for cin, cout. (mmap ver.)
 */
constexpr int SZ = 1 << 20;

class INPUT {
private:
	char* p;
	bool __END_FLAG__, __GETLINE_FLAG__;
public:
	explicit operator bool() { return !__END_FLAG__; }
	INPUT() {
		struct stat st; fstat(0, &st);
		p = (char*)mmap(0, st.st_size, PROT_READ, MAP_SHARED, 0, 0);
	}
	bool IsBlank(char c) { return c == ' ' || c == '\n'; }
	bool IsEnd(char c) { return c == '\0'; }
	char _ReadChar() { return *p++; }
	char ReadChar() {
		char ret = _ReadChar();
		for (; IsBlank(ret); ret = _ReadChar());
		return ret;
	}
	template<typename T> T ReadInt() {
		T ret = 0; char cur = _ReadChar(); bool flag = 0;
		for (; IsBlank(cur); cur = _ReadChar());
		if (cur == '-') flag = 1, cur = _ReadChar();
		for (; !IsBlank(cur) && !IsEnd(cur); cur = _ReadChar()) ret = 10 * ret + (cur & 15);
		if (IsEnd(cur)) __END_FLAG__ = 1;
		return flag ? -ret : ret;
	}
	string ReadString() {
		string ret; char cur = _ReadChar();
		for (; IsBlank(cur); cur = _ReadChar());
		for (; !IsBlank(cur) && !IsEnd(cur); cur = _ReadChar()) ret.push_back(cur);
		if (IsEnd(cur)) __END_FLAG__ = 1;
		return ret;
	}
	double ReadDouble() {
		string ret = ReadString();
		return stod(ret);
	}
	string getline() {
		string ret; char cur = _ReadChar();
		for (; cur != '\n' && !IsEnd(cur); cur = _ReadChar()) ret.push_back(cur);
		if (__GETLINE_FLAG__) __END_FLAG__ = 1;
		if (IsEnd(cur)) __GETLINE_FLAG__ = 1;
		return ret;
	}
	friend INPUT& getline(INPUT& in, string& s) { s = in.getline(); return in; }
} _in;

class OUTPUT {
private:
	char write_buf[SZ];
	int write_idx;
public:
	~OUTPUT() { Flush(); }
	explicit operator bool() { return 1; }
	void Flush() {
		write(1, write_buf, write_idx);
		write_idx = 0;
	}
	void WriteChar(char c) {
		if (write_idx == SZ) Flush();
		write_buf[write_idx++] = c;
	}
	template<typename T> int GetSize(T n) {
		int ret = 1;
		for (n = n >= 0 ? n : -n; n >= 10; n /= 10) ret++;
		return ret;
	}
	template<typename T> void WriteInt(T n) {
		int sz = GetSize(n);
		if (write_idx + sz >= SZ) Flush();
		if (n < 0) write_buf[write_idx++] = '-', n = -n;
		for (int i = sz; i-- > 0; n /= 10) write_buf[write_idx + i] = n % 10 | 48;
		write_idx += sz;
	}
	void WriteString(string s) { for (auto& c : s) WriteChar(c); }
	void WriteDouble(double d) { WriteString(to_string(d)); }
} _out;

/* operators */
INPUT& operator>> (INPUT& in, char& i) { i = in.ReadChar(); return in; }
INPUT& operator>> (INPUT& in, string& i) { i = in.ReadString(); return in; }
template<typename T, typename std::enable_if_t<is_arithmetic_v<T>>* = nullptr>
INPUT& operator>> (INPUT& in, T& i) {
	if constexpr (is_floating_point_v<T>) i = in.ReadDouble();
	else if constexpr (is_integral_v<T>) i = in.ReadInt<T>(); return in;
}

OUTPUT& operator<< (OUTPUT& out, char i) { out.WriteChar(i); return out; }
OUTPUT& operator<< (OUTPUT& out, string i) { out.WriteString(i); return out; }
template<typename T, typename std::enable_if_t<is_arithmetic_v<T>>* = nullptr>
OUTPUT& operator<< (OUTPUT& out, T i) {
	if constexpr (is_floating_point_v<T>) out.WriteDouble(i);
	else if constexpr (is_integral_v<T>) out.WriteInt<T>(i); return out;
}

/* macros */
#define fastio 1
#define cin _in
#define cout _out
#define istream INPUT
#define ostream OUTPUT
/////////////////////////////////////////////////////////////////////////////////////////////

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 1010101
#define MAXS 500
#define INF 1000000020
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000003
struct node {
	int mn;
	int mn2;
	int cnt;
	int mnl, mnr;
	node(int x = 0, int ind = 0) {
		mnl = mnr = ind;
		if (!~x) {
			mn = mn2 = cnt = -1;
			return;
		}
		mn = x;
		mn2 = INF;
		cnt = 1;
	}
};
inline node operator+(node n1, node n2) {
	if (!~n1.cnt) return n2;
	if (!~n2.cnt) return n1;
	node ret;
	ret.mn = min(n1.mn, n2.mn);
	ret.cnt = 0;
	ret.mnl = INF;
	ret.mnr = -INF;
	if (ret.mn == n1.mn) ret.cnt += n1.cnt, ret.mnl = min(ret.mnl, n1.mnl), ret.mnr = max(ret.mnr, n1.mnr);
	else ret.mn2 = min(ret.mn2, n1.mn);
	if (ret.mn == n2.mn) ret.cnt += n2.cnt, ret.mnl = min(ret.mnl, n2.mnl), ret.mnr = max(ret.mnr, n2.mnr);
	else ret.mn2 = min(ret.mn2, n2.mn);
	ret.mn2 = min(ret.mn2, n1.mn2);
	ret.mn2 = min(ret.mn2, n2.mn2);
	return ret;
}
int N;
int H[MAX];
int ch[MAX];
namespace segtree {
	int N;
	node tree[MAX * 4];
	int lazy[MAX * 4];
	void init(int s, int e, int loc = 1) {
		lazy[loc] = -1;
		if (s == e) {
			tree[loc] = node(H[s], s);
			return;
		}
		int m = s + e >> 1;
		init(s, m, loc * 2);
		init(m + 1, e, loc * 2 + 1);
		tree[loc] = tree[loc * 2] + tree[loc * 2 + 1];
	}
	inline void prop(int loc) {
		for (auto c : { loc * 2, loc * 2 + 1 }) {
			tree[c].mn = max(tree[c].mn, lazy[loc]);
			lazy[c] = max(lazy[c], lazy[loc]);
			assert(tree[c].mn < tree[c].mn2);
		}
		lazy[loc] = -1;
	}
	inline void upd(int s, int e, int l, int r, int v, int loc = 1) {
		if (s != e) prop(loc);
		if (e < l || r < s) return;
		if (l <= s && e <= r) {
			if (v < tree[loc].mn2) {
				if (v > tree[loc].mn) {
					tree[loc].mn = v;
					lazy[loc] = max(lazy[loc], v);
				}
				return;
			}
		}
		int m = s + e >> 1;
		upd(s, m, l, r, v, loc * 2);
		upd(m + 1, e, l, r, v, loc * 2 + 1);
		tree[loc] = tree[loc * 2] + tree[loc * 2 + 1];
	}
	void upd(int low, int r, int v) { upd(1, N, low, r, v); }
	inline node query(int s, int e, int l, int r, int loc = 1) {
		if (s != e) prop(loc);
		if (e < l || r < s) return node(-1);
		if (l <= s && e <= r) return tree[loc];
		int m = s + e >> 1;
		return query(s, m, l, r, loc * 2) + query(m + 1, e, l, r, loc * 2 + 1);
	}
	inline node query(int l, int r) { return query(1, N, l, r); }
}
inline ll rsum(ll n) { return (n * (n + 1) / 2) % MOD; }
inline ll rsum(ll l, ll r) { return rsum(r) - rsum(l - 1); }
namespace minseg {
	int tree[MAX * 4];
	void init(int s, int e, int loc = 1) {
		if (s == e) {
			tree[loc] = H[s];
			return;
		}
		int m = s + e >> 1;
		init(s, m, loc * 2);
		init(m + 1, e, loc * 2 + 1);
		tree[loc] = min(tree[loc * 2], tree[loc * 2 + 1]);
	}
	inline void prop(int loc) { for (auto c : { loc * 2, loc * 2 + 1 }) tree[c] = max(tree[c], tree[loc]); }
	inline void upd(int s, int e, int l, int r, int x, int loc = 1) {
		if (s != e) prop(loc);
		if (e < l || r < s) return;
		if (l <= s && e <= r) {
			tree[loc] = max(tree[loc], x);
			return;
		}
		int m = s + e >> 1;
		upd(s, m, l, r, x, loc * 2);
		upd(m + 1, e, l, r, x, loc * 2 + 1);
		tree[loc] = min(tree[loc * 2], tree[loc * 2 + 1]);
	}
	inline void upd(int l, int r, int x) { upd(1, N, l, r, x); }
	inline int get(int s, int e, int i, int loc = 1) {
		if (s != e) prop(loc);
		if (e < i || i < s) return INF;
		if (s == e) return tree[loc];
		int m = s + e >> 1;
		return min(get(s, m, i, loc * 2), get(m + 1, e, i, loc * 2 + 1));
	}
	inline int get(int i) { return get(1, N, i); }
}
signed main() {
	ios::sync_with_stdio(false);
	cin >> N;
	segtree::N = N;
	int i;
	ll ans = 0;
	int mv = 1;
	for (i = 1; i <= N; i++) cin >> H[i];
	for (i = 1; i <= N; i++) if (H[mv] < H[i]) mv = i;
	for (i = 1; i <= N; i++) ch[i] = H[i];
	for (i = 1; i <= mv; i++) ch[i] = max(ch[i], ch[i - 1]);
	for (i = N; i >= mv; i--) ch[i] = max(ch[i], ch[i + 1]);
	for (i = 1; i <= N; i++) ans += rsum(H[i], ch[i] - 1), ans %= MOD;
	segtree::init(1, N);
	minseg::init(1, N);
	int low, high;
	low = high = -1;
	for (i = 1; i < N; i++) if (H[i] > H[i + 1]) {
		low = i;
		break;
	}
	if (!~low) {
		cout << 0 << ln;
		return 0;
	}
	for (i = N; i > 1; i--) if (H[i] > H[i - 1]) {
		high = i;
		break;
	}
	if (!~high) {
		cout << 0 << ln;
		return 0;
	}
	if (low >= high) {
		cout << 0 << ln;
		return 0;
	}
	set<int> lst, rst;
	for (i = 1; i <= low; i++) lst.insert(H[i]);
	for (i = high; i <= N; i++) rst.insert(H[i]);
	int rot = 0;
	while (low < high) {
		rot++;
		assert(rot <= N * 10);
		while (low < N && minseg::get(low) <= minseg::get(low + 1)) low++, lst.insert(H[low]);
		while (high > 1 && minseg::get(high) <= minseg::get(high - 1)) high--, rst.insert(H[high]);
		if (low >= high) break;
		auto res = segtree::query(low + 1, high - 1);
		int mn = res.mn;
		int n = res.cnt;
		auto itl = lst.upper_bound(mn);
		auto itr = rst.upper_bound(mn);
		int up = min(res.mn2, min(*itl, *itr));
		int ml = min(*itl, segtree::query(low, res.mnl).mn2);
		int mr = min(*itr, segtree::query(res.mnr, high).mn2);
		if (res.cnt == 1) {
			ans += 1ll * (ml + mr) * (up - mn);
			segtree::upd(low, high, up);
			minseg::upd(low, high, up);
			ans %= MOD;
			continue;
		}
		ans += rsum(mn + 1, up) * (n * 2 - 3);
		ans %= MOD;
		ans += 1ll * (0ll + up + ml + mr) * (up - mn);
		ans %= MOD;
		segtree::upd(low, high, up);
		minseg::upd(low, high, up);
	}
	ans %= MOD;
	if (ans < 0) ans += MOD;
	cout << ans << ln;
}

Compilation message

Main.cpp: In function 'INPUT& operator>>(INPUT&, T&)':
Main.cpp:106:2: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  106 |  else if constexpr (is_integral_v<T>) i = in.ReadInt<T>(); return in;
      |  ^~~~
Main.cpp:106:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  106 |  else if constexpr (is_integral_v<T>) i = in.ReadInt<T>(); return in;
      |                                                            ^~~~~~
Main.cpp: In function 'OUTPUT& operator<<(OUTPUT&, T)':
Main.cpp:114:2: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  114 |  else if constexpr (is_integral_v<T>) out.WriteInt<T>(i); return out;
      |  ^~~~
Main.cpp:114:59: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  114 |  else if constexpr (is_integral_v<T>) out.WriteInt<T>(i); return out;
      |                                                           ^~~~~~
Main.cpp: In function 'void segtree::init(int, int, int)':
Main.cpp:181:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  181 |   int m = s + e >> 1;
      |           ~~^~~
Main.cpp: In function 'void segtree::upd(int, int, int, int, int, int)':
Main.cpp:206:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  206 |   int m = s + e >> 1;
      |           ~~^~~
Main.cpp: In function 'node segtree::query(int, int, int, int, int)':
Main.cpp:216:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  216 |   int m = s + e >> 1;
      |           ~~^~~
Main.cpp: In function 'void minseg::init(int, int, int)':
Main.cpp:230:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  230 |   int m = s + e >> 1;
      |           ~~^~~
Main.cpp: In function 'void minseg::upd(int, int, int, int, int, int)':
Main.cpp:243:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  243 |   int m = s + e >> 1;
      |           ~~^~~
Main.cpp: In function 'int minseg::get(int, int, int, int)':
Main.cpp:253:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  253 |   int m = s + e >> 1;
      |           ~~^~~
Main.cpp: In member function 'void OUTPUT::Flush()':
Main.cpp:77:8: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |   write(1, write_buf, write_idx);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 34 ms 79372 KB Output is correct
2 Correct 33 ms 79324 KB Output is correct
3 Correct 32 ms 79376 KB Output is correct
4 Correct 34 ms 79532 KB Output is correct
5 Correct 32 ms 79584 KB Output is correct
6 Correct 34 ms 79600 KB Output is correct
7 Correct 33 ms 79580 KB Output is correct
8 Correct 34 ms 79496 KB Output is correct
9 Correct 33 ms 79532 KB Output is correct
10 Correct 39 ms 79524 KB Output is correct
11 Correct 36 ms 79584 KB Output is correct
12 Correct 35 ms 79480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 79372 KB Output is correct
2 Correct 33 ms 79324 KB Output is correct
3 Correct 32 ms 79376 KB Output is correct
4 Correct 34 ms 79532 KB Output is correct
5 Correct 32 ms 79584 KB Output is correct
6 Correct 34 ms 79600 KB Output is correct
7 Correct 33 ms 79580 KB Output is correct
8 Correct 34 ms 79496 KB Output is correct
9 Correct 33 ms 79532 KB Output is correct
10 Correct 39 ms 79524 KB Output is correct
11 Correct 36 ms 79584 KB Output is correct
12 Correct 35 ms 79480 KB Output is correct
13 Correct 35 ms 79484 KB Output is correct
14 Correct 33 ms 79352 KB Output is correct
15 Correct 34 ms 79416 KB Output is correct
16 Correct 36 ms 79600 KB Output is correct
17 Correct 36 ms 79560 KB Output is correct
18 Correct 35 ms 79584 KB Output is correct
19 Correct 37 ms 79564 KB Output is correct
20 Correct 35 ms 79564 KB Output is correct
21 Correct 35 ms 79516 KB Output is correct
22 Correct 35 ms 79468 KB Output is correct
23 Correct 35 ms 79500 KB Output is correct
24 Correct 36 ms 79564 KB Output is correct
25 Correct 35 ms 79564 KB Output is correct
26 Correct 36 ms 79520 KB Output is correct
27 Correct 35 ms 79584 KB Output is correct
28 Correct 37 ms 79504 KB Output is correct
29 Correct 35 ms 79396 KB Output is correct
30 Correct 34 ms 79348 KB Output is correct
31 Correct 34 ms 79328 KB Output is correct
32 Correct 40 ms 79400 KB Output is correct
33 Correct 34 ms 79352 KB Output is correct
34 Correct 34 ms 79316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 79372 KB Output is correct
2 Correct 33 ms 79324 KB Output is correct
3 Correct 32 ms 79376 KB Output is correct
4 Correct 34 ms 79532 KB Output is correct
5 Correct 32 ms 79584 KB Output is correct
6 Correct 34 ms 79600 KB Output is correct
7 Correct 33 ms 79580 KB Output is correct
8 Correct 34 ms 79496 KB Output is correct
9 Correct 33 ms 79532 KB Output is correct
10 Correct 39 ms 79524 KB Output is correct
11 Correct 36 ms 79584 KB Output is correct
12 Correct 35 ms 79480 KB Output is correct
13 Correct 35 ms 79484 KB Output is correct
14 Correct 33 ms 79352 KB Output is correct
15 Correct 34 ms 79416 KB Output is correct
16 Correct 36 ms 79600 KB Output is correct
17 Correct 36 ms 79560 KB Output is correct
18 Correct 35 ms 79584 KB Output is correct
19 Correct 37 ms 79564 KB Output is correct
20 Correct 35 ms 79564 KB Output is correct
21 Correct 35 ms 79516 KB Output is correct
22 Correct 35 ms 79468 KB Output is correct
23 Correct 35 ms 79500 KB Output is correct
24 Correct 36 ms 79564 KB Output is correct
25 Correct 35 ms 79564 KB Output is correct
26 Correct 36 ms 79520 KB Output is correct
27 Correct 35 ms 79584 KB Output is correct
28 Correct 37 ms 79504 KB Output is correct
29 Correct 35 ms 79396 KB Output is correct
30 Correct 34 ms 79348 KB Output is correct
31 Correct 34 ms 79328 KB Output is correct
32 Correct 40 ms 79400 KB Output is correct
33 Correct 34 ms 79352 KB Output is correct
34 Correct 34 ms 79316 KB Output is correct
35 Correct 45 ms 79708 KB Output is correct
36 Correct 45 ms 79720 KB Output is correct
37 Correct 43 ms 79808 KB Output is correct
38 Correct 48 ms 79820 KB Output is correct
39 Correct 44 ms 79696 KB Output is correct
40 Correct 34 ms 79484 KB Output is correct
41 Correct 34 ms 79580 KB Output is correct
42 Correct 35 ms 79564 KB Output is correct
43 Correct 42 ms 79724 KB Output is correct
44 Correct 42 ms 79692 KB Output is correct
45 Correct 42 ms 79700 KB Output is correct
46 Correct 45 ms 79740 KB Output is correct
47 Correct 45 ms 79716 KB Output is correct
48 Correct 44 ms 79760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 79372 KB Output is correct
2 Correct 33 ms 79324 KB Output is correct
3 Correct 32 ms 79376 KB Output is correct
4 Correct 34 ms 79532 KB Output is correct
5 Correct 32 ms 79584 KB Output is correct
6 Correct 34 ms 79600 KB Output is correct
7 Correct 33 ms 79580 KB Output is correct
8 Correct 34 ms 79496 KB Output is correct
9 Correct 33 ms 79532 KB Output is correct
10 Correct 39 ms 79524 KB Output is correct
11 Correct 36 ms 79584 KB Output is correct
12 Correct 35 ms 79480 KB Output is correct
13 Correct 35 ms 79484 KB Output is correct
14 Correct 33 ms 79352 KB Output is correct
15 Correct 34 ms 79416 KB Output is correct
16 Correct 36 ms 79600 KB Output is correct
17 Correct 36 ms 79560 KB Output is correct
18 Correct 35 ms 79584 KB Output is correct
19 Correct 37 ms 79564 KB Output is correct
20 Correct 35 ms 79564 KB Output is correct
21 Correct 35 ms 79516 KB Output is correct
22 Correct 35 ms 79468 KB Output is correct
23 Correct 35 ms 79500 KB Output is correct
24 Correct 36 ms 79564 KB Output is correct
25 Correct 35 ms 79564 KB Output is correct
26 Correct 36 ms 79520 KB Output is correct
27 Correct 35 ms 79584 KB Output is correct
28 Correct 37 ms 79504 KB Output is correct
29 Correct 35 ms 79396 KB Output is correct
30 Correct 34 ms 79348 KB Output is correct
31 Correct 34 ms 79328 KB Output is correct
32 Correct 40 ms 79400 KB Output is correct
33 Correct 34 ms 79352 KB Output is correct
34 Correct 34 ms 79316 KB Output is correct
35 Correct 45 ms 79708 KB Output is correct
36 Correct 45 ms 79720 KB Output is correct
37 Correct 43 ms 79808 KB Output is correct
38 Correct 48 ms 79820 KB Output is correct
39 Correct 44 ms 79696 KB Output is correct
40 Correct 34 ms 79484 KB Output is correct
41 Correct 34 ms 79580 KB Output is correct
42 Correct 35 ms 79564 KB Output is correct
43 Correct 42 ms 79724 KB Output is correct
44 Correct 42 ms 79692 KB Output is correct
45 Correct 42 ms 79700 KB Output is correct
46 Correct 45 ms 79740 KB Output is correct
47 Correct 45 ms 79716 KB Output is correct
48 Correct 44 ms 79760 KB Output is correct
49 Correct 44 ms 79792 KB Output is correct
50 Correct 47 ms 79716 KB Output is correct
51 Correct 45 ms 79812 KB Output is correct
52 Correct 44 ms 79784 KB Output is correct
53 Correct 44 ms 79692 KB Output is correct
54 Correct 36 ms 79572 KB Output is correct
55 Correct 36 ms 79492 KB Output is correct
56 Correct 35 ms 79528 KB Output is correct
57 Correct 42 ms 79692 KB Output is correct
58 Correct 49 ms 79768 KB Output is correct
59 Correct 44 ms 79724 KB Output is correct
60 Correct 45 ms 79704 KB Output is correct
61 Correct 45 ms 79720 KB Output is correct
62 Correct 45 ms 79708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 79372 KB Output is correct
2 Correct 33 ms 79324 KB Output is correct
3 Correct 32 ms 79376 KB Output is correct
4 Correct 34 ms 79532 KB Output is correct
5 Correct 32 ms 79584 KB Output is correct
6 Correct 34 ms 79600 KB Output is correct
7 Correct 33 ms 79580 KB Output is correct
8 Correct 34 ms 79496 KB Output is correct
9 Correct 33 ms 79532 KB Output is correct
10 Correct 39 ms 79524 KB Output is correct
11 Correct 36 ms 79584 KB Output is correct
12 Correct 35 ms 79480 KB Output is correct
13 Correct 35 ms 79484 KB Output is correct
14 Correct 33 ms 79352 KB Output is correct
15 Correct 34 ms 79416 KB Output is correct
16 Correct 36 ms 79600 KB Output is correct
17 Correct 36 ms 79560 KB Output is correct
18 Correct 35 ms 79584 KB Output is correct
19 Correct 37 ms 79564 KB Output is correct
20 Correct 35 ms 79564 KB Output is correct
21 Correct 35 ms 79516 KB Output is correct
22 Correct 35 ms 79468 KB Output is correct
23 Correct 35 ms 79500 KB Output is correct
24 Correct 36 ms 79564 KB Output is correct
25 Correct 35 ms 79564 KB Output is correct
26 Correct 36 ms 79520 KB Output is correct
27 Correct 35 ms 79584 KB Output is correct
28 Correct 37 ms 79504 KB Output is correct
29 Correct 35 ms 79396 KB Output is correct
30 Correct 34 ms 79348 KB Output is correct
31 Correct 34 ms 79328 KB Output is correct
32 Correct 40 ms 79400 KB Output is correct
33 Correct 34 ms 79352 KB Output is correct
34 Correct 34 ms 79316 KB Output is correct
35 Correct 888 ms 103616 KB Output is correct
36 Correct 899 ms 103668 KB Output is correct
37 Correct 907 ms 103668 KB Output is correct
38 Correct 900 ms 103672 KB Output is correct
39 Correct 899 ms 103664 KB Output is correct
40 Correct 31 ms 79436 KB Output is correct
41 Correct 32 ms 79352 KB Output is correct
42 Correct 396 ms 103644 KB Output is correct
43 Correct 409 ms 103628 KB Output is correct
44 Correct 390 ms 103656 KB Output is correct
45 Correct 503 ms 103640 KB Output is correct
46 Correct 510 ms 103628 KB Output is correct
47 Correct 522 ms 103656 KB Output is correct
48 Correct 598 ms 103664 KB Output is correct
49 Correct 596 ms 103672 KB Output is correct
50 Correct 606 ms 103776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 79372 KB Output is correct
2 Correct 33 ms 79324 KB Output is correct
3 Correct 32 ms 79376 KB Output is correct
4 Correct 34 ms 79532 KB Output is correct
5 Correct 32 ms 79584 KB Output is correct
6 Correct 34 ms 79600 KB Output is correct
7 Correct 33 ms 79580 KB Output is correct
8 Correct 34 ms 79496 KB Output is correct
9 Correct 33 ms 79532 KB Output is correct
10 Correct 39 ms 79524 KB Output is correct
11 Correct 36 ms 79584 KB Output is correct
12 Correct 35 ms 79480 KB Output is correct
13 Correct 35 ms 79484 KB Output is correct
14 Correct 33 ms 79352 KB Output is correct
15 Correct 34 ms 79416 KB Output is correct
16 Correct 36 ms 79600 KB Output is correct
17 Correct 36 ms 79560 KB Output is correct
18 Correct 35 ms 79584 KB Output is correct
19 Correct 37 ms 79564 KB Output is correct
20 Correct 35 ms 79564 KB Output is correct
21 Correct 35 ms 79516 KB Output is correct
22 Correct 35 ms 79468 KB Output is correct
23 Correct 35 ms 79500 KB Output is correct
24 Correct 36 ms 79564 KB Output is correct
25 Correct 35 ms 79564 KB Output is correct
26 Correct 36 ms 79520 KB Output is correct
27 Correct 35 ms 79584 KB Output is correct
28 Correct 37 ms 79504 KB Output is correct
29 Correct 35 ms 79396 KB Output is correct
30 Correct 34 ms 79348 KB Output is correct
31 Correct 34 ms 79328 KB Output is correct
32 Correct 40 ms 79400 KB Output is correct
33 Correct 34 ms 79352 KB Output is correct
34 Correct 34 ms 79316 KB Output is correct
35 Correct 45 ms 79708 KB Output is correct
36 Correct 45 ms 79720 KB Output is correct
37 Correct 43 ms 79808 KB Output is correct
38 Correct 48 ms 79820 KB Output is correct
39 Correct 44 ms 79696 KB Output is correct
40 Correct 34 ms 79484 KB Output is correct
41 Correct 34 ms 79580 KB Output is correct
42 Correct 35 ms 79564 KB Output is correct
43 Correct 42 ms 79724 KB Output is correct
44 Correct 42 ms 79692 KB Output is correct
45 Correct 42 ms 79700 KB Output is correct
46 Correct 45 ms 79740 KB Output is correct
47 Correct 45 ms 79716 KB Output is correct
48 Correct 44 ms 79760 KB Output is correct
49 Correct 888 ms 103616 KB Output is correct
50 Correct 899 ms 103668 KB Output is correct
51 Correct 907 ms 103668 KB Output is correct
52 Correct 900 ms 103672 KB Output is correct
53 Correct 899 ms 103664 KB Output is correct
54 Correct 31 ms 79436 KB Output is correct
55 Correct 32 ms 79352 KB Output is correct
56 Correct 396 ms 103644 KB Output is correct
57 Correct 409 ms 103628 KB Output is correct
58 Correct 390 ms 103656 KB Output is correct
59 Correct 503 ms 103640 KB Output is correct
60 Correct 510 ms 103628 KB Output is correct
61 Correct 522 ms 103656 KB Output is correct
62 Correct 598 ms 103664 KB Output is correct
63 Correct 596 ms 103672 KB Output is correct
64 Correct 606 ms 103776 KB Output is correct
65 Correct 2956 ms 142856 KB Output is correct
66 Correct 3398 ms 157036 KB Output is correct
67 Correct 3508 ms 158340 KB Output is correct
68 Correct 3200 ms 145748 KB Output is correct
69 Correct 3050 ms 138428 KB Output is correct
70 Correct 403 ms 103660 KB Output is correct
71 Correct 403 ms 103656 KB Output is correct
72 Correct 394 ms 103656 KB Output is correct
73 Correct 1924 ms 133256 KB Output is correct
74 Correct 2340 ms 163060 KB Output is correct
75 Correct 2803 ms 163032 KB Output is correct
76 Correct 2623 ms 140528 KB Output is correct
77 Correct 2526 ms 146016 KB Output is correct
78 Correct 2614 ms 140600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 79372 KB Output is correct
2 Correct 33 ms 79324 KB Output is correct
3 Correct 32 ms 79376 KB Output is correct
4 Correct 34 ms 79532 KB Output is correct
5 Correct 32 ms 79584 KB Output is correct
6 Correct 34 ms 79600 KB Output is correct
7 Correct 33 ms 79580 KB Output is correct
8 Correct 34 ms 79496 KB Output is correct
9 Correct 33 ms 79532 KB Output is correct
10 Correct 39 ms 79524 KB Output is correct
11 Correct 36 ms 79584 KB Output is correct
12 Correct 35 ms 79480 KB Output is correct
13 Correct 35 ms 79484 KB Output is correct
14 Correct 33 ms 79352 KB Output is correct
15 Correct 34 ms 79416 KB Output is correct
16 Correct 36 ms 79600 KB Output is correct
17 Correct 36 ms 79560 KB Output is correct
18 Correct 35 ms 79584 KB Output is correct
19 Correct 37 ms 79564 KB Output is correct
20 Correct 35 ms 79564 KB Output is correct
21 Correct 35 ms 79516 KB Output is correct
22 Correct 35 ms 79468 KB Output is correct
23 Correct 35 ms 79500 KB Output is correct
24 Correct 36 ms 79564 KB Output is correct
25 Correct 35 ms 79564 KB Output is correct
26 Correct 36 ms 79520 KB Output is correct
27 Correct 35 ms 79584 KB Output is correct
28 Correct 37 ms 79504 KB Output is correct
29 Correct 35 ms 79396 KB Output is correct
30 Correct 34 ms 79348 KB Output is correct
31 Correct 34 ms 79328 KB Output is correct
32 Correct 40 ms 79400 KB Output is correct
33 Correct 34 ms 79352 KB Output is correct
34 Correct 34 ms 79316 KB Output is correct
35 Correct 45 ms 79708 KB Output is correct
36 Correct 45 ms 79720 KB Output is correct
37 Correct 43 ms 79808 KB Output is correct
38 Correct 48 ms 79820 KB Output is correct
39 Correct 44 ms 79696 KB Output is correct
40 Correct 34 ms 79484 KB Output is correct
41 Correct 34 ms 79580 KB Output is correct
42 Correct 35 ms 79564 KB Output is correct
43 Correct 42 ms 79724 KB Output is correct
44 Correct 42 ms 79692 KB Output is correct
45 Correct 42 ms 79700 KB Output is correct
46 Correct 45 ms 79740 KB Output is correct
47 Correct 45 ms 79716 KB Output is correct
48 Correct 44 ms 79760 KB Output is correct
49 Correct 44 ms 79792 KB Output is correct
50 Correct 47 ms 79716 KB Output is correct
51 Correct 45 ms 79812 KB Output is correct
52 Correct 44 ms 79784 KB Output is correct
53 Correct 44 ms 79692 KB Output is correct
54 Correct 36 ms 79572 KB Output is correct
55 Correct 36 ms 79492 KB Output is correct
56 Correct 35 ms 79528 KB Output is correct
57 Correct 42 ms 79692 KB Output is correct
58 Correct 49 ms 79768 KB Output is correct
59 Correct 44 ms 79724 KB Output is correct
60 Correct 45 ms 79704 KB Output is correct
61 Correct 45 ms 79720 KB Output is correct
62 Correct 45 ms 79708 KB Output is correct
63 Correct 888 ms 103616 KB Output is correct
64 Correct 899 ms 103668 KB Output is correct
65 Correct 907 ms 103668 KB Output is correct
66 Correct 900 ms 103672 KB Output is correct
67 Correct 899 ms 103664 KB Output is correct
68 Correct 31 ms 79436 KB Output is correct
69 Correct 32 ms 79352 KB Output is correct
70 Correct 396 ms 103644 KB Output is correct
71 Correct 409 ms 103628 KB Output is correct
72 Correct 390 ms 103656 KB Output is correct
73 Correct 503 ms 103640 KB Output is correct
74 Correct 510 ms 103628 KB Output is correct
75 Correct 522 ms 103656 KB Output is correct
76 Correct 598 ms 103664 KB Output is correct
77 Correct 596 ms 103672 KB Output is correct
78 Correct 606 ms 103776 KB Output is correct
79 Correct 2956 ms 142856 KB Output is correct
80 Correct 3398 ms 157036 KB Output is correct
81 Correct 3508 ms 158340 KB Output is correct
82 Correct 3200 ms 145748 KB Output is correct
83 Correct 3050 ms 138428 KB Output is correct
84 Correct 403 ms 103660 KB Output is correct
85 Correct 403 ms 103656 KB Output is correct
86 Correct 394 ms 103656 KB Output is correct
87 Correct 1924 ms 133256 KB Output is correct
88 Correct 2340 ms 163060 KB Output is correct
89 Correct 2803 ms 163032 KB Output is correct
90 Correct 2623 ms 140528 KB Output is correct
91 Correct 2526 ms 146016 KB Output is correct
92 Correct 2614 ms 140600 KB Output is correct
93 Correct 398 ms 103624 KB Output is correct
94 Correct 2727 ms 150552 KB Output is correct
95 Correct 2694 ms 150520 KB Output is correct
96 Correct 2702 ms 150508 KB Output is correct
97 Correct 3772 ms 150680 KB Output is correct
98 Correct 3715 ms 150528 KB Output is correct
99 Correct 3486 ms 150524 KB Output is correct
100 Correct 4262 ms 150616 KB Output is correct
101 Correct 3755 ms 150524 KB Output is correct
102 Correct 3909 ms 150564 KB Output is correct
103 Correct 4231 ms 150632 KB Output is correct
104 Correct 4447 ms 150520 KB Output is correct
105 Correct 689 ms 103660 KB Output is correct
106 Correct 477 ms 103660 KB Output is correct