Submission #566063

# Submission time Handle Problem Language Result Execution time Memory
566063 2022-05-21T17:43:21 Z ngpin04 New Home (APIO18_new_home) C++14
100 / 100
4221 ms 243628 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define TASK ""
#define bit(x) (1LL << (x))
#define getbit(x, i) (((x) >> (i)) & 1)
#define ALL(x) (x).begin(), (x).end() 
using namespace std;
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
	if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
	if (a < b) {a = b; return true;} return false;
}
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r) {
	return l + rd() % (r - l + 1);
}
const int N = 6e5 + 5; 
const int oo = 1e9;
const long long ooo = 1e18;
const int mod = 1e9 + 7; // 998244353;
const long double pi = acos(-1);

struct event {
	int y,id,t;
	event(int _y = 0, int _id = 0, int _t = 0) {
		y = _y;
		id = _id;
		t = _t;
	}

	bool operator < (const event &e) const {
		return y < e.y || (y == e.y && t < e.t);	
	}
};

struct segtree {
	bool mx;
	int n;
	vector <int> st;

	segtree(int _n = 0, bool _mx = 0) {
		mx = _mx;
		n = _n;
		st.assign((n << 2) + 5, mx ? -oo : oo);
	}	

	void update(int id, int l, int r, int pos, int val) {
		if (l > pos || r < pos)
			return;
		if (l == r) {
			st[id] = val;
			return;
		}
		int mid = (l + r) >> 1;
		update(id << 1, l, mid, pos, val);
		update(id << 1 | 1, mid + 1, r, pos, val);
		if (mx) 
			st[id] = max(st[id << 1], st[id << 1 | 1]);
		else
			st[id] = min(st[id << 1], st[id << 1 | 1]);
	}

	void update(int pos, int val) {
		update(1, 1, n, pos, val);
	}

	int getminl(int id, int l, int r, int x) {
		if (st[id] < x)
			return oo;
		if (l == r)
			return l;
		int mid = (l + r) >> 1;
		int res = getminl(id << 1, l, mid, x);
		if (res == oo)
			res = getminl(id << 1 | 1, mid + 1, r, x);
		return res;
	}

	int getminl(int x) {
		return getminl(1, 1, n, x);
	}

	int getmaxr(int id, int l, int r, int x) {
		if (st[id] > x)
			return -oo;
		if (l == r)
			return l;
		int mid = (l + r) >> 1;
		int res = getmaxr(id << 1 | 1, mid + 1, r, x);
		if (res == -oo)
			res = getmaxr(id << 1, l, mid, x);
		return res;
	}

	int getmaxr(int x) {
		return getmaxr(1, 1, n, x);
	}
};	

segtree minl, maxr;

multiset <int> candl[N];
multiset <int> candr[N];
multiset <int> pos[N];

vector <event> events;
vector <int> pos_x;

int ans[N];
int _x[N];	
int t[N];
int n,k,q,sz,cnt;

int getind(int x) {
	return upper_bound(ALL(pos_x), x) - pos_x.begin();
}

int getans(int x) {
	int pos = getind(x);
	int l = minl.getminl(pos);
	int r = maxr.getmaxr(pos);
	int res = -1;
	if (l <= pos)
		maxi(res, pos_x[pos - 1] - pos_x[l - 1]);
	if (pos <= r)
		maxi(res, pos_x[r - 1] - pos_x[pos - 1]);
	return res;
}

void updatemax(int pos) {
	maxr.update(pos, *candr[pos].begin());
}

void updatemin(int pos) {
	minl.update(pos, *prev(candl[pos].end()));
}

void add(int l, int r, int t) {
	int mid = (l + r) >> 1;
	int pl = getind(l);
	int pr = getind(r);
	int pmid = getind(mid);

	if (t > 0) {
		candl[pl].insert(pmid);
		updatemin(pl);
		if (pmid < pr) {
			candr[pr].insert(pmid + 1);
			updatemax(pr);
		}
	} else {
		candl[pl].erase(candl[pl].find(pmid));
		updatemin(pl);
		if (pmid < pr) {
			candr[pr].erase(candr[pr].find(pmid + 1));
			updatemax(pr);
		}
	}
}

void solve(vector <pair <int, int>> events) {
	for (pair <int, int> pir : events) {
		// cerr << cnt << "\n";
		int x = _x[pir.fi];
		int c = t[pir.fi];
		int p = getind(x);

		// cerr << pir.fi << " " << pir.se << " " << x << " " << c << "\n";

		if (pir.se == 2) {
			ans[pir.fi - n] = (cnt < k) ? -1 : getans(x);
			// cerr << "ans = " << ans[pir.fi - n] << "\n";
		} else if (pir.se == 0) {
			if (!pos[c].size()) {
				cnt++;			
				candr[p].insert(1);
				candl[p].insert(sz);

				updatemax(p);
				updatemin(p);
				pos[c].insert(x);
				continue;
			}

			auto it = pos[c].lower_bound(x);
			if (it == pos[c].begin()) {
				int tmp = getind(*it);

				candr[tmp].erase(candr[tmp].find(1));
				candr[p].insert(1);

				updatemax(tmp);
				updatemax(p);

				add(x, *it, 1);
				pos[c].insert(x);
				continue;
			} 

			if (it == pos[c].end()) {
				it--;
				int tmp = getind(*it);
				
				candl[tmp].erase(candl[tmp].find(sz));
				candl[p].insert(sz);
				
				updatemin(tmp);
				updatemin(p);

				add(*it, x, 1);
				pos[c].insert(x);
				continue;
			}

			int l = *prev(it);
			int r = *it;
			add(l, r, -1);
			add(l, x, 1);
			add(x, r, 1);
			
			pos[c].insert(x);
		} else {
			pos[c].erase(pos[c].find(x));

			if (!pos[c].size()) {
				candr[p].erase(candr[p].find(1));
				candl[p].erase(candl[p].find(sz));

				updatemax(p);
				updatemin(p);

				cnt--;
				continue;
			}

			auto it = pos[c].lower_bound(x);
			if (it == pos[c].begin()) {
				int tmp = getind(*it);

				candr[tmp].insert(1);
				candr[p].erase(candr[p].find(1));

				updatemax(p);
				updatemax(tmp);

				add(x, *it, -1);
				continue;
			} 

			if (it == pos[c].end()) {
				it--;	
				int tmp = getind(*it);

				candl[tmp].insert(sz);
				candl[p].erase(candl[p].find(sz));
				
				updatemin(p);
				updatemin(tmp);
				add(*it, x, -1);
				continue;
			}

			int l = *prev(it);
			int r = *it;
			add(l, r, 1);
			add(l, x, -1);
			add(x, r, -1);
		}
	}
}	

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef ONLINE_JUDGE
	// freopen(TASK".inp","r",stdin);
	// freopen(TASK".out","w",stdout);
	#endif
	cin >> n >> k >> q;
	for (int i = 1; i <= n; i++) {
		int a,b;
		cin >> _x[i] >> t[i] >> a >> b;
		events.push_back(event(a, i, 0));
		events.push_back(event(b + 1, i, 1));
		pos_x.push_back(_x[i]);
	}

	for (int i = 1; i <= q; i++) {
		int y; 
		cin >> _x[n + i] >> y;
		events.push_back(event(y, n + i, 2));
		pos_x.push_back(_x[n + i]);
	}
	sort(ALL(pos_x));
	sz = n + q;
	minl = segtree(sz, 1);
	maxr = segtree(sz, 0);

	for (int i = 1; i <= sz; i++) {
		candl[i].insert(-oo);
		candr[i].insert(oo);
	}

	sort(ALL(events));
	for (int l = 0; l < (int) events.size();) {
		int r = l;
		while (r < (int) events.size() && events[l].y == events[r].y)
			r++;

		vector <pair <int, int>> pir;
		for (int i = l; i < r; i++)
			pir.push_back(mp(events[i].id, events[i].t));

		solve(pir);
		l = r;
	}

	for (int i = 1; i <= q; i++)
		cout << ans[i] << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 38 ms 84820 KB Output is correct
2 Correct 39 ms 84860 KB Output is correct
3 Correct 38 ms 84792 KB Output is correct
4 Correct 40 ms 84800 KB Output is correct
5 Correct 42 ms 85028 KB Output is correct
6 Correct 40 ms 85056 KB Output is correct
7 Correct 40 ms 84968 KB Output is correct
8 Correct 41 ms 85048 KB Output is correct
9 Correct 41 ms 85068 KB Output is correct
10 Correct 40 ms 84976 KB Output is correct
11 Correct 41 ms 84976 KB Output is correct
12 Correct 40 ms 84952 KB Output is correct
13 Correct 40 ms 84932 KB Output is correct
14 Correct 39 ms 84988 KB Output is correct
15 Correct 40 ms 84944 KB Output is correct
16 Correct 39 ms 84976 KB Output is correct
17 Correct 40 ms 84976 KB Output is correct
18 Correct 39 ms 85060 KB Output is correct
19 Correct 42 ms 84948 KB Output is correct
20 Correct 42 ms 84940 KB Output is correct
21 Correct 40 ms 85076 KB Output is correct
22 Correct 39 ms 85084 KB Output is correct
23 Correct 39 ms 84992 KB Output is correct
24 Correct 40 ms 85016 KB Output is correct
25 Correct 41 ms 85156 KB Output is correct
26 Correct 40 ms 84940 KB Output is correct
27 Correct 38 ms 85028 KB Output is correct
28 Correct 39 ms 85000 KB Output is correct
29 Correct 40 ms 85012 KB Output is correct
30 Correct 39 ms 84904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 84820 KB Output is correct
2 Correct 39 ms 84860 KB Output is correct
3 Correct 38 ms 84792 KB Output is correct
4 Correct 40 ms 84800 KB Output is correct
5 Correct 42 ms 85028 KB Output is correct
6 Correct 40 ms 85056 KB Output is correct
7 Correct 40 ms 84968 KB Output is correct
8 Correct 41 ms 85048 KB Output is correct
9 Correct 41 ms 85068 KB Output is correct
10 Correct 40 ms 84976 KB Output is correct
11 Correct 41 ms 84976 KB Output is correct
12 Correct 40 ms 84952 KB Output is correct
13 Correct 40 ms 84932 KB Output is correct
14 Correct 39 ms 84988 KB Output is correct
15 Correct 40 ms 84944 KB Output is correct
16 Correct 39 ms 84976 KB Output is correct
17 Correct 40 ms 84976 KB Output is correct
18 Correct 39 ms 85060 KB Output is correct
19 Correct 42 ms 84948 KB Output is correct
20 Correct 42 ms 84940 KB Output is correct
21 Correct 40 ms 85076 KB Output is correct
22 Correct 39 ms 85084 KB Output is correct
23 Correct 39 ms 84992 KB Output is correct
24 Correct 40 ms 85016 KB Output is correct
25 Correct 41 ms 85156 KB Output is correct
26 Correct 40 ms 84940 KB Output is correct
27 Correct 38 ms 85028 KB Output is correct
28 Correct 39 ms 85000 KB Output is correct
29 Correct 40 ms 85012 KB Output is correct
30 Correct 39 ms 84904 KB Output is correct
31 Correct 625 ms 115308 KB Output is correct
32 Correct 301 ms 107536 KB Output is correct
33 Correct 570 ms 109864 KB Output is correct
34 Correct 604 ms 109888 KB Output is correct
35 Correct 617 ms 115192 KB Output is correct
36 Correct 607 ms 115136 KB Output is correct
37 Correct 437 ms 107328 KB Output is correct
38 Correct 468 ms 107252 KB Output is correct
39 Correct 353 ms 106644 KB Output is correct
40 Correct 371 ms 106624 KB Output is correct
41 Correct 380 ms 107008 KB Output is correct
42 Correct 356 ms 106780 KB Output is correct
43 Correct 213 ms 112952 KB Output is correct
44 Correct 373 ms 106948 KB Output is correct
45 Correct 398 ms 106888 KB Output is correct
46 Correct 353 ms 106800 KB Output is correct
47 Correct 230 ms 106044 KB Output is correct
48 Correct 230 ms 105928 KB Output is correct
49 Correct 252 ms 106292 KB Output is correct
50 Correct 271 ms 106584 KB Output is correct
51 Correct 279 ms 106240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2669 ms 229740 KB Output is correct
2 Correct 3539 ms 228388 KB Output is correct
3 Correct 1329 ms 240820 KB Output is correct
4 Correct 2267 ms 243448 KB Output is correct
5 Correct 3338 ms 240556 KB Output is correct
6 Correct 3470 ms 241016 KB Output is correct
7 Correct 1286 ms 243628 KB Output is correct
8 Correct 1786 ms 243284 KB Output is correct
9 Correct 2124 ms 243352 KB Output is correct
10 Correct 2784 ms 242188 KB Output is correct
11 Correct 1815 ms 239272 KB Output is correct
12 Correct 1956 ms 241344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3594 ms 227000 KB Output is correct
2 Correct 1666 ms 215820 KB Output is correct
3 Correct 3796 ms 238508 KB Output is correct
4 Correct 1387 ms 239152 KB Output is correct
5 Correct 2665 ms 238796 KB Output is correct
6 Correct 2362 ms 238960 KB Output is correct
7 Correct 3630 ms 237996 KB Output is correct
8 Correct 3782 ms 238408 KB Output is correct
9 Correct 1429 ms 240340 KB Output is correct
10 Correct 2295 ms 240144 KB Output is correct
11 Correct 2911 ms 240528 KB Output is correct
12 Correct 3426 ms 239452 KB Output is correct
13 Correct 1683 ms 234664 KB Output is correct
14 Correct 1613 ms 233340 KB Output is correct
15 Correct 1873 ms 236452 KB Output is correct
16 Correct 2178 ms 238508 KB Output is correct
17 Correct 2091 ms 235512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 84820 KB Output is correct
2 Correct 39 ms 84860 KB Output is correct
3 Correct 38 ms 84792 KB Output is correct
4 Correct 40 ms 84800 KB Output is correct
5 Correct 42 ms 85028 KB Output is correct
6 Correct 40 ms 85056 KB Output is correct
7 Correct 40 ms 84968 KB Output is correct
8 Correct 41 ms 85048 KB Output is correct
9 Correct 41 ms 85068 KB Output is correct
10 Correct 40 ms 84976 KB Output is correct
11 Correct 41 ms 84976 KB Output is correct
12 Correct 40 ms 84952 KB Output is correct
13 Correct 40 ms 84932 KB Output is correct
14 Correct 39 ms 84988 KB Output is correct
15 Correct 40 ms 84944 KB Output is correct
16 Correct 39 ms 84976 KB Output is correct
17 Correct 40 ms 84976 KB Output is correct
18 Correct 39 ms 85060 KB Output is correct
19 Correct 42 ms 84948 KB Output is correct
20 Correct 42 ms 84940 KB Output is correct
21 Correct 40 ms 85076 KB Output is correct
22 Correct 39 ms 85084 KB Output is correct
23 Correct 39 ms 84992 KB Output is correct
24 Correct 40 ms 85016 KB Output is correct
25 Correct 41 ms 85156 KB Output is correct
26 Correct 40 ms 84940 KB Output is correct
27 Correct 38 ms 85028 KB Output is correct
28 Correct 39 ms 85000 KB Output is correct
29 Correct 40 ms 85012 KB Output is correct
30 Correct 39 ms 84904 KB Output is correct
31 Correct 625 ms 115308 KB Output is correct
32 Correct 301 ms 107536 KB Output is correct
33 Correct 570 ms 109864 KB Output is correct
34 Correct 604 ms 109888 KB Output is correct
35 Correct 617 ms 115192 KB Output is correct
36 Correct 607 ms 115136 KB Output is correct
37 Correct 437 ms 107328 KB Output is correct
38 Correct 468 ms 107252 KB Output is correct
39 Correct 353 ms 106644 KB Output is correct
40 Correct 371 ms 106624 KB Output is correct
41 Correct 380 ms 107008 KB Output is correct
42 Correct 356 ms 106780 KB Output is correct
43 Correct 213 ms 112952 KB Output is correct
44 Correct 373 ms 106948 KB Output is correct
45 Correct 398 ms 106888 KB Output is correct
46 Correct 353 ms 106800 KB Output is correct
47 Correct 230 ms 106044 KB Output is correct
48 Correct 230 ms 105928 KB Output is correct
49 Correct 252 ms 106292 KB Output is correct
50 Correct 271 ms 106584 KB Output is correct
51 Correct 279 ms 106240 KB Output is correct
52 Correct 290 ms 115084 KB Output is correct
53 Correct 290 ms 109780 KB Output is correct
54 Correct 459 ms 115072 KB Output is correct
55 Correct 388 ms 109856 KB Output is correct
56 Correct 359 ms 111192 KB Output is correct
57 Correct 469 ms 107768 KB Output is correct
58 Correct 405 ms 109792 KB Output is correct
59 Correct 383 ms 111060 KB Output is correct
60 Correct 478 ms 107692 KB Output is correct
61 Correct 226 ms 116280 KB Output is correct
62 Correct 338 ms 115200 KB Output is correct
63 Correct 492 ms 113792 KB Output is correct
64 Correct 505 ms 112368 KB Output is correct
65 Correct 567 ms 108736 KB Output is correct
66 Correct 533 ms 107084 KB Output is correct
67 Correct 445 ms 107132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 84820 KB Output is correct
2 Correct 39 ms 84860 KB Output is correct
3 Correct 38 ms 84792 KB Output is correct
4 Correct 40 ms 84800 KB Output is correct
5 Correct 42 ms 85028 KB Output is correct
6 Correct 40 ms 85056 KB Output is correct
7 Correct 40 ms 84968 KB Output is correct
8 Correct 41 ms 85048 KB Output is correct
9 Correct 41 ms 85068 KB Output is correct
10 Correct 40 ms 84976 KB Output is correct
11 Correct 41 ms 84976 KB Output is correct
12 Correct 40 ms 84952 KB Output is correct
13 Correct 40 ms 84932 KB Output is correct
14 Correct 39 ms 84988 KB Output is correct
15 Correct 40 ms 84944 KB Output is correct
16 Correct 39 ms 84976 KB Output is correct
17 Correct 40 ms 84976 KB Output is correct
18 Correct 39 ms 85060 KB Output is correct
19 Correct 42 ms 84948 KB Output is correct
20 Correct 42 ms 84940 KB Output is correct
21 Correct 40 ms 85076 KB Output is correct
22 Correct 39 ms 85084 KB Output is correct
23 Correct 39 ms 84992 KB Output is correct
24 Correct 40 ms 85016 KB Output is correct
25 Correct 41 ms 85156 KB Output is correct
26 Correct 40 ms 84940 KB Output is correct
27 Correct 38 ms 85028 KB Output is correct
28 Correct 39 ms 85000 KB Output is correct
29 Correct 40 ms 85012 KB Output is correct
30 Correct 39 ms 84904 KB Output is correct
31 Correct 625 ms 115308 KB Output is correct
32 Correct 301 ms 107536 KB Output is correct
33 Correct 570 ms 109864 KB Output is correct
34 Correct 604 ms 109888 KB Output is correct
35 Correct 617 ms 115192 KB Output is correct
36 Correct 607 ms 115136 KB Output is correct
37 Correct 437 ms 107328 KB Output is correct
38 Correct 468 ms 107252 KB Output is correct
39 Correct 353 ms 106644 KB Output is correct
40 Correct 371 ms 106624 KB Output is correct
41 Correct 380 ms 107008 KB Output is correct
42 Correct 356 ms 106780 KB Output is correct
43 Correct 213 ms 112952 KB Output is correct
44 Correct 373 ms 106948 KB Output is correct
45 Correct 398 ms 106888 KB Output is correct
46 Correct 353 ms 106800 KB Output is correct
47 Correct 230 ms 106044 KB Output is correct
48 Correct 230 ms 105928 KB Output is correct
49 Correct 252 ms 106292 KB Output is correct
50 Correct 271 ms 106584 KB Output is correct
51 Correct 279 ms 106240 KB Output is correct
52 Correct 2669 ms 229740 KB Output is correct
53 Correct 3539 ms 228388 KB Output is correct
54 Correct 1329 ms 240820 KB Output is correct
55 Correct 2267 ms 243448 KB Output is correct
56 Correct 3338 ms 240556 KB Output is correct
57 Correct 3470 ms 241016 KB Output is correct
58 Correct 1286 ms 243628 KB Output is correct
59 Correct 1786 ms 243284 KB Output is correct
60 Correct 2124 ms 243352 KB Output is correct
61 Correct 2784 ms 242188 KB Output is correct
62 Correct 1815 ms 239272 KB Output is correct
63 Correct 1956 ms 241344 KB Output is correct
64 Correct 3594 ms 227000 KB Output is correct
65 Correct 1666 ms 215820 KB Output is correct
66 Correct 3796 ms 238508 KB Output is correct
67 Correct 1387 ms 239152 KB Output is correct
68 Correct 2665 ms 238796 KB Output is correct
69 Correct 2362 ms 238960 KB Output is correct
70 Correct 3630 ms 237996 KB Output is correct
71 Correct 3782 ms 238408 KB Output is correct
72 Correct 1429 ms 240340 KB Output is correct
73 Correct 2295 ms 240144 KB Output is correct
74 Correct 2911 ms 240528 KB Output is correct
75 Correct 3426 ms 239452 KB Output is correct
76 Correct 1683 ms 234664 KB Output is correct
77 Correct 1613 ms 233340 KB Output is correct
78 Correct 1873 ms 236452 KB Output is correct
79 Correct 2178 ms 238508 KB Output is correct
80 Correct 2091 ms 235512 KB Output is correct
81 Correct 290 ms 115084 KB Output is correct
82 Correct 290 ms 109780 KB Output is correct
83 Correct 459 ms 115072 KB Output is correct
84 Correct 388 ms 109856 KB Output is correct
85 Correct 359 ms 111192 KB Output is correct
86 Correct 469 ms 107768 KB Output is correct
87 Correct 405 ms 109792 KB Output is correct
88 Correct 383 ms 111060 KB Output is correct
89 Correct 478 ms 107692 KB Output is correct
90 Correct 226 ms 116280 KB Output is correct
91 Correct 338 ms 115200 KB Output is correct
92 Correct 492 ms 113792 KB Output is correct
93 Correct 505 ms 112368 KB Output is correct
94 Correct 567 ms 108736 KB Output is correct
95 Correct 533 ms 107084 KB Output is correct
96 Correct 445 ms 107132 KB Output is correct
97 Correct 1831 ms 236288 KB Output is correct
98 Correct 2260 ms 199212 KB Output is correct
99 Correct 4219 ms 209228 KB Output is correct
100 Correct 1649 ms 209688 KB Output is correct
101 Correct 2767 ms 236188 KB Output is correct
102 Correct 4221 ms 235780 KB Output is correct
103 Correct 3272 ms 197012 KB Output is correct
104 Correct 3106 ms 196472 KB Output is correct
105 Correct 1891 ms 193736 KB Output is correct
106 Correct 1976 ms 193920 KB Output is correct
107 Correct 1985 ms 210008 KB Output is correct
108 Correct 1911 ms 216828 KB Output is correct
109 Correct 2165 ms 199940 KB Output is correct
110 Correct 2068 ms 209296 KB Output is correct
111 Correct 1931 ms 216472 KB Output is correct
112 Correct 2173 ms 199548 KB Output is correct
113 Correct 776 ms 242176 KB Output is correct
114 Correct 1505 ms 236968 KB Output is correct
115 Correct 2128 ms 229864 KB Output is correct
116 Correct 2373 ms 222940 KB Output is correct
117 Correct 2589 ms 204720 KB Output is correct
118 Correct 2477 ms 196312 KB Output is correct
119 Correct 3021 ms 196552 KB Output is correct
120 Correct 938 ms 188024 KB Output is correct
121 Correct 1129 ms 191192 KB Output is correct
122 Correct 1116 ms 190888 KB Output is correct
123 Correct 1270 ms 192348 KB Output is correct
124 Correct 1391 ms 193684 KB Output is correct
125 Correct 1335 ms 192972 KB Output is correct
126 Correct 1393 ms 194004 KB Output is correct