Submission #213252

# Submission time Handle Problem Language Result Execution time Memory
213252 2020-03-25T11:18:37 Z zscoder Two Dishes (JOI19_dishes) C++17
100 / 100
8130 ms 369528 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<ll> a,b,s,p,q,t;
vector<ii> F[1001111];
const ll INF = ll(3e18);
vector<pair<ii,ll> > G[1001111];

struct node
{
	ll v;
	ll upd,add;
};

node st[4000011];

void build(int id, int l, int r)
{
	st[id].v=st[id].add=0; //i shouldn't have -ves anyway, or should I?
	st[id].upd=-INF;
	if(r-l<2) return ;
	int mid=(l+r)>>1;
	build(id*2,l,mid); build(id*2+1,mid,r);
}

void combine(int id)
{
	st[id].v=max(st[id*2].v,st[id*2+1].v);
}

void push(int id, int l, int r)
{
	if(st[id].upd!=-INF)
	{
		st[id].v=st[id].upd;
		if(r-l>=2)
		{
			st[id*2].upd=st[id].upd; st[id*2].add=0;
			st[id*2+1].upd=st[id].upd; st[id*2+1].add=0;
		}
	}
	if(st[id].add!=0)
	{
		st[id].v+=st[id].add;
		if(r-l>=2)
		{
			st[id*2].add+=st[id].add;
			st[id*2+1].add+=st[id].add; 
		}
	}
	st[id].upd=-INF; st[id].add=0;
}

void update(int id, int l, int r, int ql, int qr, ll v)
{
	push(id,l,r);
	if(ql>=r||l>=qr) return ;
	if(l>=ql&&r<=qr) 
	{
		//cerr<<l<<' '<<r<<' '<<ql<<' '<<qr<<' '<<v<<'\n';
		st[id].upd=v; st[id].add=0;
		push(id,l,r); return ;
	}
	int mid=(l+r)>>1;
	update(id*2,l,mid,ql,qr,v); update(id*2+1,mid,r,ql,qr,v);
	combine(id);
}

void add(int id, int l, int r, int ql, int qr, ll v)
{
	push(id,l,r);
	if(ql>=r||l>=qr) return ;
	if(l>=ql&&r<=qr) 
	{
		//assert(st[id].upd==-INF);
		st[id].add+=v;
		push(id,l,r); return ;
	}
	int mid=(l+r)>>1;
	add(id*2,l,mid,ql,qr,v); add(id*2+1,mid,r,ql,qr,v);
	combine(id);
}

int find_left(int id, int l, int r, ll x) //or none?
{
	push(id,l,r);
	if(st[id].v<x) return -1;
	if(r-l<2) return l;
	int mid=(l+r)>>1;
	ll val = st[id*2].v;
	if(st[id*2].upd!=-INF) val=st[id*2].upd;
	val+=st[id*2].add;
	if(val>=x)
	{
		return find_left(id*2,l,mid,x);
	}
	else
	{
		return find_left(id*2+1,mid,r,x);
	}
}

ll query(int id, int l, int r, int ql, int qr)
{
	push(id,l,r);
	if(ql>=r||l>=qr) return -INF;
	if(l>=ql&&r<=qr) return st[id].v;
	int mid=(l+r)>>1;
	return max(query(id*2,l,mid,ql,qr),query(id*2+1,mid,r,ql,qr));
}

ll dp[2111][2111];

int main()
{
	//freopen("03-03.txt","r",stdin);
	int n,m; scanf("%d %d",&n,&m);
	a.resize(n); s.resize(n); p.resize(n);
	b.resize(m); t.resize(m); q.resize(m);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld %lld",&a[i],&s[i],&p[i]);
		if(i>0) a[i]+=a[i-1];
	}
	for(int i=0;i<m;i++)
	{
		scanf("%lld %lld %lld",&b[i],&t[i],&q[i]);
		if(i>0) b[i]+=b[i-1];
	}
	ll ans = 0;
	for(int i=0;i<m;i++)
	{
		if(b[i]>t[i]) continue;
		if(b[i]+a[n-1]<=t[i]) {ans+=q[i]; continue;}
		//min j such that b_i+a_j>t[i]
		int ptr = upper_bound(a.begin(),a.end(),t[i]-b[i])-a.begin();
		ans+=q[i];
		//cerr<<i<<' '<<ptr+1<<'\n';
		F[i].pb({ptr+1,-q[i]});
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]>s[i]) continue;
		if(a[i]+b[m-1]<=s[i]){ans+=p[i]; continue;}
		int ptr = upper_bound(b.begin(),b.end(),s[i]-a[i])-b.begin();
		ptr--;
		//cerr<<ptr+1<<' '<<i+1<<' '<<p[i]<<'\n';
		F[ptr+1].pb({i+1,p[i]});
	}
	for(int i=0;i<m;i++)
	{
		sort(F[i].begin(),F[i].end());
		ll sum=0; int l=0;
		for(int j=0;j<F[i].size();j++)
		{
			//cerr<<i<<' '<<F[i][j].fi<<' '<<F[i][j].se<<'\n';
			if(j+1<F[i].size()&&F[i][j+1].fi==F[i][j].fi)
			{
				F[i][j+1].se+=F[i][j].se; continue;
			}
			if(l<=F[i][j].fi-1)
			{
				G[i].pb({{l,F[i][j].fi-1},sum});
			}
			l=F[i][j].fi;
			sum+=F[i][j].se;
		}
		if(l<=n) G[i].pb({{l,n},sum});
	}
	build(1,0,n+1);
	for(int i=0;i<m;i++)
	{
		vector<pair<ii,ii> > updates;
		ll lasnum = -INF*2;
		
		for(int j=0;j<G[i].size();j++)
		{
			int l = G[i][j].fi.fi; int r = G[i][j].fi.se; ll v = G[i][j].se;
			//cerr<<"UPDATE : "<<i<<' '<<l<<' '<<r<<' '<<v<<'\n'; cerr<<"LASNUM = "<<lasnum<<'\n';
			
			int gleft = find_left(1,0,n+1,lasnum-v+1);
			//cerr<<"GLEFT : "<<gleft<<'\n';
			if(gleft==-1) gleft=n+100;
			
			if(l<=gleft-1) updates.pb({{l,min(r,gleft-1)},{1,lasnum}});
			if(gleft<=r) updates.pb({{max(gleft,l),r},{0,v}});
			if(gleft<=r) lasnum=max(lasnum,v+query(1,0,n+1,r,r+1));
		}
		for(auto X:updates)
		{
			if(X.se.fi) update(1,0,n+1,X.fi.fi,X.fi.se+1,X.se.se); //update
			else add(1,0,n+1,X.fi.fi,X.fi.se+1,X.se.se);
		}
		
		/*
		for(int j=0;j<G[i].size();j++)
		{
			int l = G[i][j].fi.fi; int r = G[i][j].fi.se; ll v = G[i][j].se;
			for(int k=l;k<=r;k++)
			{
				dp[i+1][k]=dp[i][k]+v;
			}
		}
		for(int k=1;k<=n;k++) dp[i+1][k]=max(dp[i+1][k],dp[i+1][k-1]);
		
		bool problem=0;
		for(int j=0;j<=n;j++)
		{
			if(dp[i+1][j]!=query(1,0,n+1,j,j+1)){problem=1; break;}
		}
		if(problem)
		{
			cerr<<"ROW "<<i+1<<'\n';
			for(int j=0;j<=n;j++)
			{
				cerr<<dp[i+1][j]<<' ';
			}
			cerr<<'\n';
			for(int j=0;j<=n;j++)
			{
				cerr<<query(1,0,n+1,j,j+1)<<' ';
			}
			cerr<<'\n';
			cerr<<'\n';
		}
		*/
		/*
		for(int j=0;j<=n;j++)
		{
			query(1,0,n+1,j,j+1);
		}
		*/
	}
	//cout<<ans+dp[m][n]<<'\n';
	cout<<query(1,0,n+1,0,n+1)+ans<<'\n';
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:172:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<F[i].size();j++)
               ~^~~~~~~~~~~~
dishes.cpp:175:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j+1<F[i].size()&&F[i][j+1].fi==F[i][j].fi)
       ~~~^~~~~~~~~~~~
dishes.cpp:194:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<G[i].size();j++)
               ~^~~~~~~~~~~~
dishes.cpp:135:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n,m; scanf("%d %d",&n,&m);
           ~~~~~^~~~~~~~~~~~~~~
dishes.cpp:140:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&a[i],&s[i],&p[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:145:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&b[i],&t[i],&q[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 581 ms 106360 KB Output is correct
2 Correct 688 ms 105592 KB Output is correct
3 Correct 333 ms 88696 KB Output is correct
4 Correct 497 ms 98808 KB Output is correct
5 Correct 29 ms 47352 KB Output is correct
6 Correct 645 ms 101752 KB Output is correct
7 Correct 164 ms 65144 KB Output is correct
8 Correct 140 ms 71420 KB Output is correct
9 Correct 334 ms 89720 KB Output is correct
10 Correct 652 ms 98424 KB Output is correct
11 Correct 292 ms 83192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 47360 KB Output is correct
2 Correct 29 ms 47360 KB Output is correct
3 Correct 29 ms 47360 KB Output is correct
4 Correct 31 ms 47360 KB Output is correct
5 Correct 29 ms 47360 KB Output is correct
6 Correct 31 ms 47360 KB Output is correct
7 Correct 29 ms 47360 KB Output is correct
8 Correct 29 ms 47360 KB Output is correct
9 Correct 30 ms 47360 KB Output is correct
10 Correct 29 ms 47488 KB Output is correct
11 Correct 29 ms 47352 KB Output is correct
12 Correct 31 ms 47360 KB Output is correct
13 Correct 29 ms 47352 KB Output is correct
14 Correct 29 ms 47360 KB Output is correct
15 Correct 32 ms 47352 KB Output is correct
16 Correct 31 ms 47352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 47360 KB Output is correct
2 Correct 29 ms 47360 KB Output is correct
3 Correct 29 ms 47360 KB Output is correct
4 Correct 31 ms 47360 KB Output is correct
5 Correct 29 ms 47360 KB Output is correct
6 Correct 31 ms 47360 KB Output is correct
7 Correct 29 ms 47360 KB Output is correct
8 Correct 29 ms 47360 KB Output is correct
9 Correct 30 ms 47360 KB Output is correct
10 Correct 29 ms 47488 KB Output is correct
11 Correct 29 ms 47352 KB Output is correct
12 Correct 31 ms 47360 KB Output is correct
13 Correct 29 ms 47352 KB Output is correct
14 Correct 29 ms 47360 KB Output is correct
15 Correct 32 ms 47352 KB Output is correct
16 Correct 31 ms 47352 KB Output is correct
17 Correct 33 ms 47872 KB Output is correct
18 Correct 33 ms 47872 KB Output is correct
19 Correct 38 ms 48000 KB Output is correct
20 Correct 37 ms 47864 KB Output is correct
21 Correct 36 ms 47872 KB Output is correct
22 Correct 37 ms 47872 KB Output is correct
23 Correct 37 ms 47872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 47360 KB Output is correct
2 Correct 29 ms 47360 KB Output is correct
3 Correct 29 ms 47360 KB Output is correct
4 Correct 31 ms 47360 KB Output is correct
5 Correct 29 ms 47360 KB Output is correct
6 Correct 31 ms 47360 KB Output is correct
7 Correct 29 ms 47360 KB Output is correct
8 Correct 29 ms 47360 KB Output is correct
9 Correct 30 ms 47360 KB Output is correct
10 Correct 29 ms 47488 KB Output is correct
11 Correct 29 ms 47352 KB Output is correct
12 Correct 31 ms 47360 KB Output is correct
13 Correct 29 ms 47352 KB Output is correct
14 Correct 29 ms 47360 KB Output is correct
15 Correct 32 ms 47352 KB Output is correct
16 Correct 31 ms 47352 KB Output is correct
17 Correct 33 ms 47872 KB Output is correct
18 Correct 33 ms 47872 KB Output is correct
19 Correct 38 ms 48000 KB Output is correct
20 Correct 37 ms 47864 KB Output is correct
21 Correct 36 ms 47872 KB Output is correct
22 Correct 37 ms 47872 KB Output is correct
23 Correct 37 ms 47872 KB Output is correct
24 Correct 494 ms 106072 KB Output is correct
25 Correct 494 ms 98424 KB Output is correct
26 Correct 645 ms 98552 KB Output is correct
27 Correct 521 ms 98552 KB Output is correct
28 Correct 606 ms 92408 KB Output is correct
29 Correct 310 ms 86648 KB Output is correct
30 Correct 1289 ms 110328 KB Output is correct
31 Correct 190 ms 69880 KB Output is correct
32 Correct 217 ms 79716 KB Output is correct
33 Correct 820 ms 97528 KB Output is correct
34 Correct 940 ms 104312 KB Output is correct
35 Correct 1234 ms 104312 KB Output is correct
36 Correct 1255 ms 103416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 47360 KB Output is correct
2 Correct 29 ms 47360 KB Output is correct
3 Correct 29 ms 47360 KB Output is correct
4 Correct 31 ms 47360 KB Output is correct
5 Correct 29 ms 47360 KB Output is correct
6 Correct 31 ms 47360 KB Output is correct
7 Correct 29 ms 47360 KB Output is correct
8 Correct 29 ms 47360 KB Output is correct
9 Correct 30 ms 47360 KB Output is correct
10 Correct 29 ms 47488 KB Output is correct
11 Correct 29 ms 47352 KB Output is correct
12 Correct 31 ms 47360 KB Output is correct
13 Correct 29 ms 47352 KB Output is correct
14 Correct 29 ms 47360 KB Output is correct
15 Correct 32 ms 47352 KB Output is correct
16 Correct 31 ms 47352 KB Output is correct
17 Correct 33 ms 47872 KB Output is correct
18 Correct 33 ms 47872 KB Output is correct
19 Correct 38 ms 48000 KB Output is correct
20 Correct 37 ms 47864 KB Output is correct
21 Correct 36 ms 47872 KB Output is correct
22 Correct 37 ms 47872 KB Output is correct
23 Correct 37 ms 47872 KB Output is correct
24 Correct 494 ms 106072 KB Output is correct
25 Correct 494 ms 98424 KB Output is correct
26 Correct 645 ms 98552 KB Output is correct
27 Correct 521 ms 98552 KB Output is correct
28 Correct 606 ms 92408 KB Output is correct
29 Correct 310 ms 86648 KB Output is correct
30 Correct 1289 ms 110328 KB Output is correct
31 Correct 190 ms 69880 KB Output is correct
32 Correct 217 ms 79716 KB Output is correct
33 Correct 820 ms 97528 KB Output is correct
34 Correct 940 ms 104312 KB Output is correct
35 Correct 1234 ms 104312 KB Output is correct
36 Correct 1255 ms 103416 KB Output is correct
37 Correct 660 ms 101624 KB Output is correct
38 Correct 586 ms 101368 KB Output is correct
39 Correct 772 ms 102008 KB Output is correct
40 Correct 632 ms 102008 KB Output is correct
41 Correct 29 ms 47232 KB Output is correct
42 Correct 1398 ms 113400 KB Output is correct
43 Correct 851 ms 100472 KB Output is correct
44 Correct 1012 ms 107000 KB Output is correct
45 Correct 1242 ms 107512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 47360 KB Output is correct
2 Correct 29 ms 47360 KB Output is correct
3 Correct 29 ms 47360 KB Output is correct
4 Correct 31 ms 47360 KB Output is correct
5 Correct 29 ms 47360 KB Output is correct
6 Correct 31 ms 47360 KB Output is correct
7 Correct 29 ms 47360 KB Output is correct
8 Correct 29 ms 47360 KB Output is correct
9 Correct 30 ms 47360 KB Output is correct
10 Correct 29 ms 47488 KB Output is correct
11 Correct 29 ms 47352 KB Output is correct
12 Correct 31 ms 47360 KB Output is correct
13 Correct 29 ms 47352 KB Output is correct
14 Correct 29 ms 47360 KB Output is correct
15 Correct 32 ms 47352 KB Output is correct
16 Correct 31 ms 47352 KB Output is correct
17 Correct 33 ms 47872 KB Output is correct
18 Correct 33 ms 47872 KB Output is correct
19 Correct 38 ms 48000 KB Output is correct
20 Correct 37 ms 47864 KB Output is correct
21 Correct 36 ms 47872 KB Output is correct
22 Correct 37 ms 47872 KB Output is correct
23 Correct 37 ms 47872 KB Output is correct
24 Correct 494 ms 106072 KB Output is correct
25 Correct 494 ms 98424 KB Output is correct
26 Correct 645 ms 98552 KB Output is correct
27 Correct 521 ms 98552 KB Output is correct
28 Correct 606 ms 92408 KB Output is correct
29 Correct 310 ms 86648 KB Output is correct
30 Correct 1289 ms 110328 KB Output is correct
31 Correct 190 ms 69880 KB Output is correct
32 Correct 217 ms 79716 KB Output is correct
33 Correct 820 ms 97528 KB Output is correct
34 Correct 940 ms 104312 KB Output is correct
35 Correct 1234 ms 104312 KB Output is correct
36 Correct 1255 ms 103416 KB Output is correct
37 Correct 660 ms 101624 KB Output is correct
38 Correct 586 ms 101368 KB Output is correct
39 Correct 772 ms 102008 KB Output is correct
40 Correct 632 ms 102008 KB Output is correct
41 Correct 29 ms 47232 KB Output is correct
42 Correct 1398 ms 113400 KB Output is correct
43 Correct 851 ms 100472 KB Output is correct
44 Correct 1012 ms 107000 KB Output is correct
45 Correct 1242 ms 107512 KB Output is correct
46 Correct 3244 ms 307576 KB Output is correct
47 Correct 2789 ms 307576 KB Output is correct
48 Correct 4174 ms 309524 KB Output is correct
49 Correct 3385 ms 309624 KB Output is correct
50 Correct 8130 ms 368944 KB Output is correct
51 Correct 5092 ms 297592 KB Output is correct
52 Correct 5090 ms 318072 KB Output is correct
53 Correct 7317 ms 332664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 581 ms 106360 KB Output is correct
2 Correct 688 ms 105592 KB Output is correct
3 Correct 333 ms 88696 KB Output is correct
4 Correct 497 ms 98808 KB Output is correct
5 Correct 29 ms 47352 KB Output is correct
6 Correct 645 ms 101752 KB Output is correct
7 Correct 164 ms 65144 KB Output is correct
8 Correct 140 ms 71420 KB Output is correct
9 Correct 334 ms 89720 KB Output is correct
10 Correct 652 ms 98424 KB Output is correct
11 Correct 292 ms 83192 KB Output is correct
12 Correct 31 ms 47360 KB Output is correct
13 Correct 29 ms 47360 KB Output is correct
14 Correct 29 ms 47360 KB Output is correct
15 Correct 31 ms 47360 KB Output is correct
16 Correct 29 ms 47360 KB Output is correct
17 Correct 31 ms 47360 KB Output is correct
18 Correct 29 ms 47360 KB Output is correct
19 Correct 29 ms 47360 KB Output is correct
20 Correct 30 ms 47360 KB Output is correct
21 Correct 29 ms 47488 KB Output is correct
22 Correct 29 ms 47352 KB Output is correct
23 Correct 31 ms 47360 KB Output is correct
24 Correct 29 ms 47352 KB Output is correct
25 Correct 29 ms 47360 KB Output is correct
26 Correct 32 ms 47352 KB Output is correct
27 Correct 31 ms 47352 KB Output is correct
28 Correct 33 ms 47872 KB Output is correct
29 Correct 33 ms 47872 KB Output is correct
30 Correct 38 ms 48000 KB Output is correct
31 Correct 37 ms 47864 KB Output is correct
32 Correct 36 ms 47872 KB Output is correct
33 Correct 37 ms 47872 KB Output is correct
34 Correct 37 ms 47872 KB Output is correct
35 Correct 494 ms 106072 KB Output is correct
36 Correct 494 ms 98424 KB Output is correct
37 Correct 645 ms 98552 KB Output is correct
38 Correct 521 ms 98552 KB Output is correct
39 Correct 606 ms 92408 KB Output is correct
40 Correct 310 ms 86648 KB Output is correct
41 Correct 1289 ms 110328 KB Output is correct
42 Correct 190 ms 69880 KB Output is correct
43 Correct 217 ms 79716 KB Output is correct
44 Correct 820 ms 97528 KB Output is correct
45 Correct 940 ms 104312 KB Output is correct
46 Correct 1234 ms 104312 KB Output is correct
47 Correct 1255 ms 103416 KB Output is correct
48 Correct 660 ms 101624 KB Output is correct
49 Correct 586 ms 101368 KB Output is correct
50 Correct 772 ms 102008 KB Output is correct
51 Correct 632 ms 102008 KB Output is correct
52 Correct 29 ms 47232 KB Output is correct
53 Correct 1398 ms 113400 KB Output is correct
54 Correct 851 ms 100472 KB Output is correct
55 Correct 1012 ms 107000 KB Output is correct
56 Correct 1242 ms 107512 KB Output is correct
57 Correct 563 ms 102008 KB Output is correct
58 Correct 659 ms 102008 KB Output is correct
59 Correct 638 ms 103032 KB Output is correct
60 Correct 820 ms 103032 KB Output is correct
61 Correct 904 ms 111352 KB Output is correct
62 Correct 32 ms 47352 KB Output is correct
63 Correct 1331 ms 113528 KB Output is correct
64 Correct 854 ms 100216 KB Output is correct
65 Correct 1093 ms 107384 KB Output is correct
66 Correct 1213 ms 106744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 581 ms 106360 KB Output is correct
2 Correct 688 ms 105592 KB Output is correct
3 Correct 333 ms 88696 KB Output is correct
4 Correct 497 ms 98808 KB Output is correct
5 Correct 29 ms 47352 KB Output is correct
6 Correct 645 ms 101752 KB Output is correct
7 Correct 164 ms 65144 KB Output is correct
8 Correct 140 ms 71420 KB Output is correct
9 Correct 334 ms 89720 KB Output is correct
10 Correct 652 ms 98424 KB Output is correct
11 Correct 292 ms 83192 KB Output is correct
12 Correct 31 ms 47360 KB Output is correct
13 Correct 29 ms 47360 KB Output is correct
14 Correct 29 ms 47360 KB Output is correct
15 Correct 31 ms 47360 KB Output is correct
16 Correct 29 ms 47360 KB Output is correct
17 Correct 31 ms 47360 KB Output is correct
18 Correct 29 ms 47360 KB Output is correct
19 Correct 29 ms 47360 KB Output is correct
20 Correct 30 ms 47360 KB Output is correct
21 Correct 29 ms 47488 KB Output is correct
22 Correct 29 ms 47352 KB Output is correct
23 Correct 31 ms 47360 KB Output is correct
24 Correct 29 ms 47352 KB Output is correct
25 Correct 29 ms 47360 KB Output is correct
26 Correct 32 ms 47352 KB Output is correct
27 Correct 31 ms 47352 KB Output is correct
28 Correct 33 ms 47872 KB Output is correct
29 Correct 33 ms 47872 KB Output is correct
30 Correct 38 ms 48000 KB Output is correct
31 Correct 37 ms 47864 KB Output is correct
32 Correct 36 ms 47872 KB Output is correct
33 Correct 37 ms 47872 KB Output is correct
34 Correct 37 ms 47872 KB Output is correct
35 Correct 494 ms 106072 KB Output is correct
36 Correct 494 ms 98424 KB Output is correct
37 Correct 645 ms 98552 KB Output is correct
38 Correct 521 ms 98552 KB Output is correct
39 Correct 606 ms 92408 KB Output is correct
40 Correct 310 ms 86648 KB Output is correct
41 Correct 1289 ms 110328 KB Output is correct
42 Correct 190 ms 69880 KB Output is correct
43 Correct 217 ms 79716 KB Output is correct
44 Correct 820 ms 97528 KB Output is correct
45 Correct 940 ms 104312 KB Output is correct
46 Correct 1234 ms 104312 KB Output is correct
47 Correct 1255 ms 103416 KB Output is correct
48 Correct 660 ms 101624 KB Output is correct
49 Correct 586 ms 101368 KB Output is correct
50 Correct 772 ms 102008 KB Output is correct
51 Correct 632 ms 102008 KB Output is correct
52 Correct 29 ms 47232 KB Output is correct
53 Correct 1398 ms 113400 KB Output is correct
54 Correct 851 ms 100472 KB Output is correct
55 Correct 1012 ms 107000 KB Output is correct
56 Correct 1242 ms 107512 KB Output is correct
57 Correct 3244 ms 307576 KB Output is correct
58 Correct 2789 ms 307576 KB Output is correct
59 Correct 4174 ms 309524 KB Output is correct
60 Correct 3385 ms 309624 KB Output is correct
61 Correct 8130 ms 368944 KB Output is correct
62 Correct 5092 ms 297592 KB Output is correct
63 Correct 5090 ms 318072 KB Output is correct
64 Correct 7317 ms 332664 KB Output is correct
65 Correct 563 ms 102008 KB Output is correct
66 Correct 659 ms 102008 KB Output is correct
67 Correct 638 ms 103032 KB Output is correct
68 Correct 820 ms 103032 KB Output is correct
69 Correct 904 ms 111352 KB Output is correct
70 Correct 32 ms 47352 KB Output is correct
71 Correct 1331 ms 113528 KB Output is correct
72 Correct 854 ms 100216 KB Output is correct
73 Correct 1093 ms 107384 KB Output is correct
74 Correct 1213 ms 106744 KB Output is correct
75 Correct 2850 ms 309368 KB Output is correct
76 Correct 3339 ms 309368 KB Output is correct
77 Correct 3212 ms 312056 KB Output is correct
78 Correct 4019 ms 312056 KB Output is correct
79 Correct 7844 ms 369528 KB Output is correct
80 Correct 4632 ms 295928 KB Output is correct
81 Correct 5638 ms 323960 KB Output is correct
82 Correct 7639 ms 335992 KB Output is correct
83 Correct 7328 ms 348280 KB Output is correct