Submission #163572

# Submission time Handle Problem Language Result Execution time Memory
163572 2019-11-13T22:47:09 Z TadijaSebez Two Dishes (JOI19_dishes) C++11
10 / 100
10000 ms 64256 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=1e6+50;
const int M=2*N;
const ll inf=3e18;
ll ckmx(ll &a, ll b){ return a=max(a,b);}
int ls[M],rs[M],tsz,root;
ll lzy[M][2],mx[M];
void Upd(int c, ll x, int t){ t==0?mx[c]+=x,lzy[c][0]+=x,lzy[c][1]+=x:ckmx(mx[c],x),ckmx(lzy[c][1],x);}
void Push(int c)
{
	Upd(ls[c],lzy[c][0],0);Upd(ls[c],lzy[c][1],1);
	Upd(rs[c],lzy[c][0],0);Upd(rs[c],lzy[c][1],1);
	lzy[c][0]=0;lzy[c][1]=-inf;
}
ll ans[N];
void Set(int c, int ss, int se, int qs, int qe, ll x, int t)
{
for(int i=qs;i<=qe;i++)
{
if(t==0) ans[i]+=x;
else ckmx(ans[i],x);
}
}
ll Get(int c, int ss, int se, int qi)
{
return ans[qi];
}
void Build(int &c, int ss, int se)
{
	c=++tsz;mx[c]=lzy[c][0]=0;lzy[c][1]=-inf;
	if(ss==se) return;
	int mid=ss+se>>1;
	Build(ls[c],ss,mid);
	Build(rs[c],mid+1,se);
}
ll a[N],s[N],p[N],b[N],t[N],q[N];
vector<pair<int,ll>> Us[N];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i+1]>>s[i]>>p[i],a[i+1]+=a[i];
	for(int i=0;i<m;i++) cin>>b[i+1]>>t[i]>>q[i],b[i+1]+=b[i];
	for(int i=0;i<n;i++)
	{
		int j=upper_bound(b,b+m+1,s[i]-a[i+1])-b-1;
		if(j>=0) Us[j].pb({i+1,p[i]});
	}
	ll sum=0;
	for(int i=0;i<m;i++)
	{
		sum+=q[i];
		int j=upper_bound(a,a+n+1,t[i]-b[i+1])-a-1;
		if(j<n) Us[i].pb({j+1,-q[i]});
	}
	Build(root,0,n);
	for(int i=0;i<=m;i++)
	{
		for(auto u:Us[i]) Set(root,0,n,u.first,n,u.second,0);
		if(i==m) break;
		for(auto u:Us[i]) if(u.first) Set(root,0,n,u.first,n,Get(root,0,n,u.first-1),1);
	}
	cout<<sum+Get(root,0,n,n)<<endl;
	return 0;
}

Compilation message

dishes.cpp: In function 'void Build(int&, int, int)':
dishes.cpp:35:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=ss+se>>1;
          ~~^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 10023 ms 56472 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 23928 KB Output is correct
2 Correct 23 ms 23928 KB Output is correct
3 Correct 24 ms 23928 KB Output is correct
4 Correct 23 ms 23928 KB Output is correct
5 Correct 24 ms 23928 KB Output is correct
6 Correct 24 ms 23840 KB Output is correct
7 Correct 23 ms 23928 KB Output is correct
8 Correct 24 ms 23928 KB Output is correct
9 Correct 25 ms 23928 KB Output is correct
10 Correct 26 ms 23928 KB Output is correct
11 Correct 24 ms 23928 KB Output is correct
12 Correct 24 ms 23928 KB Output is correct
13 Correct 23 ms 23928 KB Output is correct
14 Correct 24 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 23928 KB Output is correct
2 Correct 23 ms 23928 KB Output is correct
3 Correct 24 ms 23928 KB Output is correct
4 Correct 23 ms 23928 KB Output is correct
5 Correct 24 ms 23928 KB Output is correct
6 Correct 24 ms 23840 KB Output is correct
7 Correct 23 ms 23928 KB Output is correct
8 Correct 24 ms 23928 KB Output is correct
9 Correct 25 ms 23928 KB Output is correct
10 Correct 26 ms 23928 KB Output is correct
11 Correct 24 ms 23928 KB Output is correct
12 Correct 24 ms 23928 KB Output is correct
13 Correct 23 ms 23928 KB Output is correct
14 Correct 24 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 32 ms 24312 KB Output is correct
18 Correct 33 ms 24408 KB Output is correct
19 Correct 33 ms 24312 KB Output is correct
20 Correct 30 ms 24312 KB Output is correct
21 Correct 37 ms 24312 KB Output is correct
22 Correct 32 ms 24312 KB Output is correct
23 Correct 31 ms 24312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 23928 KB Output is correct
2 Correct 23 ms 23928 KB Output is correct
3 Correct 24 ms 23928 KB Output is correct
4 Correct 23 ms 23928 KB Output is correct
5 Correct 24 ms 23928 KB Output is correct
6 Correct 24 ms 23840 KB Output is correct
7 Correct 23 ms 23928 KB Output is correct
8 Correct 24 ms 23928 KB Output is correct
9 Correct 25 ms 23928 KB Output is correct
10 Correct 26 ms 23928 KB Output is correct
11 Correct 24 ms 23928 KB Output is correct
12 Correct 24 ms 23928 KB Output is correct
13 Correct 23 ms 23928 KB Output is correct
14 Correct 24 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 32 ms 24312 KB Output is correct
18 Correct 33 ms 24408 KB Output is correct
19 Correct 33 ms 24312 KB Output is correct
20 Correct 30 ms 24312 KB Output is correct
21 Correct 37 ms 24312 KB Output is correct
22 Correct 32 ms 24312 KB Output is correct
23 Correct 31 ms 24312 KB Output is correct
24 Execution timed out 10022 ms 64256 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 23928 KB Output is correct
2 Correct 23 ms 23928 KB Output is correct
3 Correct 24 ms 23928 KB Output is correct
4 Correct 23 ms 23928 KB Output is correct
5 Correct 24 ms 23928 KB Output is correct
6 Correct 24 ms 23840 KB Output is correct
7 Correct 23 ms 23928 KB Output is correct
8 Correct 24 ms 23928 KB Output is correct
9 Correct 25 ms 23928 KB Output is correct
10 Correct 26 ms 23928 KB Output is correct
11 Correct 24 ms 23928 KB Output is correct
12 Correct 24 ms 23928 KB Output is correct
13 Correct 23 ms 23928 KB Output is correct
14 Correct 24 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 32 ms 24312 KB Output is correct
18 Correct 33 ms 24408 KB Output is correct
19 Correct 33 ms 24312 KB Output is correct
20 Correct 30 ms 24312 KB Output is correct
21 Correct 37 ms 24312 KB Output is correct
22 Correct 32 ms 24312 KB Output is correct
23 Correct 31 ms 24312 KB Output is correct
24 Execution timed out 10022 ms 64256 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 23928 KB Output is correct
2 Correct 23 ms 23928 KB Output is correct
3 Correct 24 ms 23928 KB Output is correct
4 Correct 23 ms 23928 KB Output is correct
5 Correct 24 ms 23928 KB Output is correct
6 Correct 24 ms 23840 KB Output is correct
7 Correct 23 ms 23928 KB Output is correct
8 Correct 24 ms 23928 KB Output is correct
9 Correct 25 ms 23928 KB Output is correct
10 Correct 26 ms 23928 KB Output is correct
11 Correct 24 ms 23928 KB Output is correct
12 Correct 24 ms 23928 KB Output is correct
13 Correct 23 ms 23928 KB Output is correct
14 Correct 24 ms 23936 KB Output is correct
15 Correct 24 ms 23928 KB Output is correct
16 Correct 25 ms 23928 KB Output is correct
17 Correct 32 ms 24312 KB Output is correct
18 Correct 33 ms 24408 KB Output is correct
19 Correct 33 ms 24312 KB Output is correct
20 Correct 30 ms 24312 KB Output is correct
21 Correct 37 ms 24312 KB Output is correct
22 Correct 32 ms 24312 KB Output is correct
23 Correct 31 ms 24312 KB Output is correct
24 Execution timed out 10022 ms 64256 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10023 ms 56472 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10023 ms 56472 KB Time limit exceeded
2 Halted 0 ms 0 KB -