답안 #285484

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
285484 2020-08-29T07:03:04 Z arnold518 Progression (NOI20_progression) C++14
100 / 100
1954 ms 95504 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 3e5;

int N, Q;
ll A[MAXN+10];

struct Node
{
	ll sum, len, cnt, lval, lcnt, rval, rcnt;
	Node() : sum(0), len(0), cnt(0), lval(-1), lcnt(0), rval(-1), rcnt(0) {}
};

Node operator + (const Node &p, const Node &q)
{
	Node ret;
	ret.sum=p.sum+q.sum;
	ret.len=p.len+q.len;
	ret.lval=p.lval;
	ret.lcnt=p.lcnt;
	if(p.lcnt==p.len && q.lval==p.lval) ret.lcnt=p.lcnt+q.lcnt;
	ret.rval=q.rval;
	ret.rcnt=q.rcnt;
	if(q.rcnt==q.len && p.rval==q.rval) ret.rcnt=p.rcnt+q.rcnt;
	ret.cnt=max(p.cnt, q.cnt);
	if(p.rval==q.lval) ret.cnt=max(ret.cnt, p.rcnt+q.lcnt);
	return ret;	
}

Node tree[MAXN*4+10];
pll lazy[MAXN*4+10];

void busy(int node, int tl, int tr)
{
	if(lazy[node].first==0) return;
	else if(lazy[node].first==1)
	{
		tree[node].sum+=lazy[node].second*tree[node].len;
		tree[node].lval+=lazy[node].second;
		tree[node].rval+=lazy[node].second;

		if(tl!=tr)
		{
			if(lazy[node*2].first==0) lazy[node*2]=lazy[node];
			else lazy[node*2].second+=lazy[node].second;

			if(lazy[node*2+1].first==0) lazy[node*2+1]=lazy[node];
			else lazy[node*2+1].second+=lazy[node].second;			
		}
	}
	else if(lazy[node].first==2)
	{
		tree[node].sum=lazy[node].second*tree[node].len;
		tree[node].cnt=tree[node].lcnt=tree[node].rcnt=tree[node].len;
		tree[node].lval=tree[node].rval=lazy[node].second;

		if(tl!=tr)
		{
			lazy[node*2]=lazy[node];
			lazy[node*2+1]=lazy[node];
		}
	}
	lazy[node]=pll(0, 0);
}

void init(int node, int tl, int tr)
{
	if(tl==tr)
	{
		tree[node].sum=A[tl];
		tree[node].len=1;
		tree[node].cnt=tree[node].lcnt=tree[node].rcnt=1;
		tree[node].lval=tree[node].rval=A[tl];
		return;
	}
	int mid=tl+tr>>1;
	init(node*2, tl, mid);
	init(node*2+1, mid+1, tr);
	tree[node]=tree[node*2]+tree[node*2+1];
}

void update1(int node, int tl, int tr, int l, int r, ll k)
{
	l=max(1, l); r=min(N, r);
	if(l>r) return;
	busy(node, tl, tr);
	if(r<tl || tr<l) return;
	if(l<=tl && tr<=r)
	{
		lazy[node]=pll(1, k);
		busy(node, tl, tr);
		return;
	}
	int mid=tl+tr>>1;
	update1(node*2, tl, mid, l, r, k);
	update1(node*2+1, mid+1, tr, l, r, k);
	tree[node]=tree[node*2]+tree[node*2+1];
}

void update2(int node, int tl, int tr, int l, int r, ll k)
{
	l=max(1, l); r=min(N, r);
	if(r>N) return;
	busy(node, tl, tr);
	if(r<tl || tr<l) return;
	if(l<=tl && tr<=r)
	{
		lazy[node]=pll(2, k);
		busy(node, tl, tr);
		return;
	}
	int mid=tl+tr>>1;
	update2(node*2, tl, mid, l, r, k);
	update2(node*2+1, mid+1, tr, l, r, k);
	tree[node]=tree[node*2]+tree[node*2+1];
}

Node query(int node, int tl, int tr, int l, int r)
{
	l=max(1, l); r=min(N, r);
	if(l>r) return Node();
	busy(node, tl, tr);
	if(l==tl && tr==r) return tree[node];
	int mid=tl+tr>>1;
	if(r<=mid) return query(node*2, tl, mid, l, r);
	if(mid+1<=l) return query(node*2+1, mid+1, tr, l, r);
	return query(node*2, tl, mid, l, mid)+query(node*2+1, mid+1, tr, mid+1, r);
}

void debug(int node, int tl, int tr)
{
	busy(node, tl, tr);
	if(tl==tr) return;
	int mid=tl+tr>>1;
	debug(node*2, tl, mid);
	debug(node*2+1, mid+1, tr);
	tree[node]=tree[node*2]+tree[node*2+1];
	Node &t=tree[node];
	printf("DEBUG %d %d : sum %lld len %lld cnt %lld lval %lld lcnt %lld rval %lld rcnt %lld\n", tl, tr, t.sum, t.len, t.cnt, t.lval, t.lcnt, t.rval, t.rcnt);
}

int main()
{
	scanf("%d%d", &N, &Q);
	for(int i=1; i<=N; i++) scanf("%lld", &A[i]);

	for(int i=N; i>=1; i--) A[i]=A[i]-A[i-1];
	init(1, 1, N);

	while(Q--)
	{
		//for(int i=1; i<=N; i++) printf("%lld ", query(1, 1, N, 1, i).sum); printf("\n");
		//debug(1, 1, N);
		int t, l, r, s, c;
		scanf("%d", &t);
		if(t==1)
		{
			scanf("%d%d%d%d", &l, &r, &s, &c);
			int t=query(1, 1, N, 1, r+1).sum;
			update1(1, 1, N, l+1, r, c);
			update1(1, 1, N, l, l, s);
			t-=query(1, 1, N, 1, r).sum;
			update2(1, 1, N, r+1, r+1, t);
		}
		else if(t==2)
		{
			scanf("%d%d%d%d", &l, &r, &s, &c);
			int t=query(1, 1, N, 1, r+1).sum;
			update2(1, 1, N, l+1, r, c);
			update2(1, 1, N, l, l, -query(1, 1, N, 1, l-1).sum+s);
			t-=query(1, 1, N, 1, r).sum;
			update2(1, 1, N, r+1, r+1, t);
		}
		else if(t==3)
		{
			int l, r;
			scanf("%d%d", &l, &r);
			if(l==r) printf("1\n");
			else printf("%d\n", query(1, 1, N, l+1, r).cnt+1);
			Node t=query(1, 1, N, l+1, r);
			//printf("Query %lld %lld %lld %lld %lld %lld %lld\n", t.sum, t.len, t.cnt, t.lval, t.lcnt, t.rval, t.rcnt);
		}
	}
}

Compilation message

Progression.cpp: In function 'void init(int, int, int)':
Progression.cpp:81:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   81 |  int mid=tl+tr>>1;
      |          ~~^~~
Progression.cpp: In function 'void update1(int, int, int, int, int, ll)':
Progression.cpp:99:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   99 |  int mid=tl+tr>>1;
      |          ~~^~~
Progression.cpp: In function 'void update2(int, int, int, int, int, ll)':
Progression.cpp:117:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  117 |  int mid=tl+tr>>1;
      |          ~~^~~
Progression.cpp: In function 'Node query(int, int, int, int, int)':
Progression.cpp:129:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  129 |  int mid=tl+tr>>1;
      |          ~~^~~
Progression.cpp: In function 'void debug(int, int, int)':
Progression.cpp:139:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  139 |  int mid=tl+tr>>1;
      |          ~~^~~
Progression.cpp: In function 'int main()':
Progression.cpp:184:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
  184 |    else printf("%d\n", query(1, 1, N, l+1, r).cnt+1);
      |                 ~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  |                               |
      |                  int                             ll {aka long long int}
      |                 %lld
Progression.cpp:185:9: warning: variable 't' set but not used [-Wunused-but-set-variable]
  185 |    Node t=query(1, 1, N, l+1, r);
      |         ^
Progression.cpp:149:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  149 |  scanf("%d%d", &N, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~
Progression.cpp:150:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  150 |  for(int i=1; i<=N; i++) scanf("%lld", &A[i]);
      |                          ~~~~~^~~~~~~~~~~~~~~
Progression.cpp:160:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  160 |   scanf("%d", &t);
      |   ~~~~~^~~~~~~~~~
Progression.cpp:163:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  163 |    scanf("%d%d%d%d", &l, &r, &s, &c);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Progression.cpp:172:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  172 |    scanf("%d%d%d%d", &l, &r, &s, &c);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Progression.cpp:182:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  182 |    scanf("%d%d", &l, &r);
      |    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 619 ms 70136 KB Output is correct
2 Correct 268 ms 67544 KB Output is correct
3 Correct 273 ms 67448 KB Output is correct
4 Correct 270 ms 67448 KB Output is correct
5 Correct 274 ms 67428 KB Output is correct
6 Correct 272 ms 67448 KB Output is correct
7 Correct 273 ms 67448 KB Output is correct
8 Correct 40 ms 66044 KB Output is correct
9 Correct 38 ms 66048 KB Output is correct
10 Correct 39 ms 66040 KB Output is correct
11 Correct 608 ms 70136 KB Output is correct
12 Correct 614 ms 70136 KB Output is correct
13 Correct 608 ms 70392 KB Output is correct
14 Correct 618 ms 70392 KB Output is correct
15 Correct 614 ms 70392 KB Output is correct
16 Correct 635 ms 70196 KB Output is correct
17 Correct 616 ms 70088 KB Output is correct
18 Correct 617 ms 70136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 66172 KB Output is correct
2 Correct 39 ms 66048 KB Output is correct
3 Correct 40 ms 66040 KB Output is correct
4 Correct 39 ms 66048 KB Output is correct
5 Correct 42 ms 66168 KB Output is correct
6 Correct 39 ms 66040 KB Output is correct
7 Correct 39 ms 66040 KB Output is correct
8 Correct 40 ms 66168 KB Output is correct
9 Correct 40 ms 66168 KB Output is correct
10 Correct 40 ms 66168 KB Output is correct
11 Correct 40 ms 66192 KB Output is correct
12 Correct 40 ms 66176 KB Output is correct
13 Correct 40 ms 66168 KB Output is correct
14 Correct 40 ms 66168 KB Output is correct
15 Correct 42 ms 66204 KB Output is correct
16 Correct 42 ms 66168 KB Output is correct
17 Correct 42 ms 66168 KB Output is correct
18 Correct 40 ms 66168 KB Output is correct
19 Correct 42 ms 66040 KB Output is correct
20 Correct 40 ms 66048 KB Output is correct
21 Correct 40 ms 66040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 553 ms 70648 KB Output is correct
2 Correct 208 ms 67704 KB Output is correct
3 Correct 193 ms 67704 KB Output is correct
4 Correct 167 ms 67704 KB Output is correct
5 Correct 214 ms 67832 KB Output is correct
6 Correct 214 ms 67832 KB Output is correct
7 Correct 210 ms 67704 KB Output is correct
8 Correct 40 ms 66040 KB Output is correct
9 Correct 39 ms 66040 KB Output is correct
10 Correct 39 ms 66040 KB Output is correct
11 Correct 676 ms 70008 KB Output is correct
12 Correct 576 ms 70124 KB Output is correct
13 Correct 646 ms 69880 KB Output is correct
14 Correct 663 ms 69752 KB Output is correct
15 Correct 548 ms 70136 KB Output is correct
16 Correct 674 ms 70748 KB Output is correct
17 Correct 695 ms 70572 KB Output is correct
18 Correct 696 ms 70776 KB Output is correct
19 Correct 612 ms 69964 KB Output is correct
20 Correct 590 ms 69880 KB Output is correct
21 Correct 552 ms 69884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1178 ms 81912 KB Output is correct
2 Correct 313 ms 67088 KB Output is correct
3 Correct 316 ms 69384 KB Output is correct
4 Correct 306 ms 69496 KB Output is correct
5 Correct 311 ms 69520 KB Output is correct
6 Correct 314 ms 69496 KB Output is correct
7 Correct 316 ms 69496 KB Output is correct
8 Correct 39 ms 66040 KB Output is correct
9 Correct 40 ms 66136 KB Output is correct
10 Correct 39 ms 66040 KB Output is correct
11 Correct 1207 ms 87316 KB Output is correct
12 Correct 1162 ms 90812 KB Output is correct
13 Correct 1165 ms 87408 KB Output is correct
14 Correct 1191 ms 87576 KB Output is correct
15 Correct 1084 ms 90580 KB Output is correct
16 Correct 1215 ms 90744 KB Output is correct
17 Correct 1201 ms 90744 KB Output is correct
18 Correct 1203 ms 90872 KB Output is correct
19 Correct 1117 ms 90620 KB Output is correct
20 Correct 1138 ms 90616 KB Output is correct
21 Correct 1159 ms 90608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 553 ms 70648 KB Output is correct
2 Correct 208 ms 67704 KB Output is correct
3 Correct 193 ms 67704 KB Output is correct
4 Correct 167 ms 67704 KB Output is correct
5 Correct 214 ms 67832 KB Output is correct
6 Correct 214 ms 67832 KB Output is correct
7 Correct 210 ms 67704 KB Output is correct
8 Correct 40 ms 66040 KB Output is correct
9 Correct 39 ms 66040 KB Output is correct
10 Correct 39 ms 66040 KB Output is correct
11 Correct 676 ms 70008 KB Output is correct
12 Correct 576 ms 70124 KB Output is correct
13 Correct 646 ms 69880 KB Output is correct
14 Correct 663 ms 69752 KB Output is correct
15 Correct 548 ms 70136 KB Output is correct
16 Correct 674 ms 70748 KB Output is correct
17 Correct 695 ms 70572 KB Output is correct
18 Correct 696 ms 70776 KB Output is correct
19 Correct 612 ms 69964 KB Output is correct
20 Correct 590 ms 69880 KB Output is correct
21 Correct 552 ms 69884 KB Output is correct
22 Correct 1732 ms 86544 KB Output is correct
23 Correct 324 ms 67776 KB Output is correct
24 Correct 329 ms 67708 KB Output is correct
25 Correct 296 ms 67704 KB Output is correct
26 Correct 319 ms 67704 KB Output is correct
27 Correct 313 ms 67876 KB Output is correct
28 Correct 313 ms 67704 KB Output is correct
29 Correct 40 ms 66040 KB Output is correct
30 Correct 39 ms 66040 KB Output is correct
31 Correct 39 ms 66040 KB Output is correct
32 Correct 1627 ms 86628 KB Output is correct
33 Correct 1549 ms 86628 KB Output is correct
34 Correct 1592 ms 86520 KB Output is correct
35 Correct 1599 ms 86648 KB Output is correct
36 Correct 1334 ms 86904 KB Output is correct
37 Correct 1321 ms 87032 KB Output is correct
38 Correct 1333 ms 86980 KB Output is correct
39 Correct 1559 ms 86648 KB Output is correct
40 Correct 1630 ms 86656 KB Output is correct
41 Correct 1684 ms 86336 KB Output is correct
42 Correct 1664 ms 86076 KB Output is correct
43 Correct 1578 ms 86008 KB Output is correct
44 Correct 1601 ms 86044 KB Output is correct
45 Correct 1547 ms 86188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 619 ms 70136 KB Output is correct
2 Correct 268 ms 67544 KB Output is correct
3 Correct 273 ms 67448 KB Output is correct
4 Correct 270 ms 67448 KB Output is correct
5 Correct 274 ms 67428 KB Output is correct
6 Correct 272 ms 67448 KB Output is correct
7 Correct 273 ms 67448 KB Output is correct
8 Correct 40 ms 66044 KB Output is correct
9 Correct 38 ms 66048 KB Output is correct
10 Correct 39 ms 66040 KB Output is correct
11 Correct 608 ms 70136 KB Output is correct
12 Correct 614 ms 70136 KB Output is correct
13 Correct 608 ms 70392 KB Output is correct
14 Correct 618 ms 70392 KB Output is correct
15 Correct 614 ms 70392 KB Output is correct
16 Correct 635 ms 70196 KB Output is correct
17 Correct 616 ms 70088 KB Output is correct
18 Correct 617 ms 70136 KB Output is correct
19 Correct 42 ms 66172 KB Output is correct
20 Correct 39 ms 66048 KB Output is correct
21 Correct 40 ms 66040 KB Output is correct
22 Correct 39 ms 66048 KB Output is correct
23 Correct 42 ms 66168 KB Output is correct
24 Correct 39 ms 66040 KB Output is correct
25 Correct 39 ms 66040 KB Output is correct
26 Correct 40 ms 66168 KB Output is correct
27 Correct 40 ms 66168 KB Output is correct
28 Correct 40 ms 66168 KB Output is correct
29 Correct 40 ms 66192 KB Output is correct
30 Correct 40 ms 66176 KB Output is correct
31 Correct 40 ms 66168 KB Output is correct
32 Correct 40 ms 66168 KB Output is correct
33 Correct 42 ms 66204 KB Output is correct
34 Correct 42 ms 66168 KB Output is correct
35 Correct 42 ms 66168 KB Output is correct
36 Correct 40 ms 66168 KB Output is correct
37 Correct 42 ms 66040 KB Output is correct
38 Correct 40 ms 66048 KB Output is correct
39 Correct 40 ms 66040 KB Output is correct
40 Correct 553 ms 70648 KB Output is correct
41 Correct 208 ms 67704 KB Output is correct
42 Correct 193 ms 67704 KB Output is correct
43 Correct 167 ms 67704 KB Output is correct
44 Correct 214 ms 67832 KB Output is correct
45 Correct 214 ms 67832 KB Output is correct
46 Correct 210 ms 67704 KB Output is correct
47 Correct 40 ms 66040 KB Output is correct
48 Correct 39 ms 66040 KB Output is correct
49 Correct 39 ms 66040 KB Output is correct
50 Correct 676 ms 70008 KB Output is correct
51 Correct 576 ms 70124 KB Output is correct
52 Correct 646 ms 69880 KB Output is correct
53 Correct 663 ms 69752 KB Output is correct
54 Correct 548 ms 70136 KB Output is correct
55 Correct 674 ms 70748 KB Output is correct
56 Correct 695 ms 70572 KB Output is correct
57 Correct 696 ms 70776 KB Output is correct
58 Correct 612 ms 69964 KB Output is correct
59 Correct 590 ms 69880 KB Output is correct
60 Correct 552 ms 69884 KB Output is correct
61 Correct 1178 ms 81912 KB Output is correct
62 Correct 313 ms 67088 KB Output is correct
63 Correct 316 ms 69384 KB Output is correct
64 Correct 306 ms 69496 KB Output is correct
65 Correct 311 ms 69520 KB Output is correct
66 Correct 314 ms 69496 KB Output is correct
67 Correct 316 ms 69496 KB Output is correct
68 Correct 39 ms 66040 KB Output is correct
69 Correct 40 ms 66136 KB Output is correct
70 Correct 39 ms 66040 KB Output is correct
71 Correct 1207 ms 87316 KB Output is correct
72 Correct 1162 ms 90812 KB Output is correct
73 Correct 1165 ms 87408 KB Output is correct
74 Correct 1191 ms 87576 KB Output is correct
75 Correct 1084 ms 90580 KB Output is correct
76 Correct 1215 ms 90744 KB Output is correct
77 Correct 1201 ms 90744 KB Output is correct
78 Correct 1203 ms 90872 KB Output is correct
79 Correct 1117 ms 90620 KB Output is correct
80 Correct 1138 ms 90616 KB Output is correct
81 Correct 1159 ms 90608 KB Output is correct
82 Correct 1732 ms 86544 KB Output is correct
83 Correct 324 ms 67776 KB Output is correct
84 Correct 329 ms 67708 KB Output is correct
85 Correct 296 ms 67704 KB Output is correct
86 Correct 319 ms 67704 KB Output is correct
87 Correct 313 ms 67876 KB Output is correct
88 Correct 313 ms 67704 KB Output is correct
89 Correct 40 ms 66040 KB Output is correct
90 Correct 39 ms 66040 KB Output is correct
91 Correct 39 ms 66040 KB Output is correct
92 Correct 1627 ms 86628 KB Output is correct
93 Correct 1549 ms 86628 KB Output is correct
94 Correct 1592 ms 86520 KB Output is correct
95 Correct 1599 ms 86648 KB Output is correct
96 Correct 1334 ms 86904 KB Output is correct
97 Correct 1321 ms 87032 KB Output is correct
98 Correct 1333 ms 86980 KB Output is correct
99 Correct 1559 ms 86648 KB Output is correct
100 Correct 1630 ms 86656 KB Output is correct
101 Correct 1684 ms 86336 KB Output is correct
102 Correct 1664 ms 86076 KB Output is correct
103 Correct 1578 ms 86008 KB Output is correct
104 Correct 1601 ms 86044 KB Output is correct
105 Correct 1547 ms 86188 KB Output is correct
106 Correct 1848 ms 95108 KB Output is correct
107 Correct 374 ms 69624 KB Output is correct
108 Correct 359 ms 69496 KB Output is correct
109 Correct 363 ms 69504 KB Output is correct
110 Correct 39 ms 66040 KB Output is correct
111 Correct 39 ms 66040 KB Output is correct
112 Correct 39 ms 66044 KB Output is correct
113 Correct 1684 ms 94376 KB Output is correct
114 Correct 1715 ms 94448 KB Output is correct
115 Correct 1726 ms 94164 KB Output is correct
116 Correct 1564 ms 94328 KB Output is correct
117 Correct 1859 ms 95196 KB Output is correct
118 Correct 1632 ms 94152 KB Output is correct
119 Correct 1587 ms 94328 KB Output is correct
120 Correct 675 ms 76408 KB Output is correct
121 Correct 680 ms 76280 KB Output is correct
122 Correct 668 ms 76408 KB Output is correct
123 Correct 568 ms 75512 KB Output is correct
124 Correct 583 ms 75512 KB Output is correct
125 Correct 546 ms 75512 KB Output is correct
126 Correct 1828 ms 91896 KB Output is correct
127 Correct 1797 ms 91896 KB Output is correct
128 Correct 1843 ms 95220 KB Output is correct
129 Correct 1912 ms 91768 KB Output is correct
130 Correct 1376 ms 91996 KB Output is correct
131 Correct 1397 ms 91948 KB Output is correct
132 Correct 1368 ms 92216 KB Output is correct
133 Correct 1825 ms 95504 KB Output is correct
134 Correct 1954 ms 95272 KB Output is correct
135 Correct 1916 ms 95480 KB Output is correct
136 Correct 358 ms 69624 KB Output is correct
137 Correct 362 ms 69516 KB Output is correct
138 Correct 361 ms 69496 KB Output is correct