Submission #707338

# Submission time Handle Problem Language Result Execution time Memory
707338 2023-03-08T19:43:59 Z amirhoseinfar1385 Pinball (JOI14_pinball) C++17
0 / 100
14 ms 33108 KB
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long inf=1e15,kaf=(1<<20);
struct segment{
	long long seg[(1<<21)];
	segment(){
		for(int i=0;i<(1<<21);i++){
			seg[i]=inf;
		}
	}
	void upd(int i,long long w){
		if(i==0){
			return ;
		}	
		seg[i]=min(seg[i],w);
		return upd((i>>1),w);
	}
	long long pors(int i,int l,int r,int tl,int tr){
		if(l>r||l>tr||r<tl){
			return inf;
		}
		if(l>=tl&&r<=tr){
			return seg[i];
		}	
		int m=(l+r)>>1;
		long long ret=min(pors((i<<1),l,m,tl,tr),pors((i<<1)^1,m+1,r,tl,tr));
		return ret;
	}
};
segment seg1,seg2;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	long long res=inf;
	seg1.upd(kaf+1,0);
	seg2.upd(kaf+m,0);
	for(int i=0;i<n;i++){
		long long l,r,c,w;
		cin>>w>>c>>l>>r;
		long long fake=seg1.pors(1,0,kaf-1,l,r)+seg2.pors(1,0,kaf-1,l,r);
		fake+=w;
		res=min(fake,res);
		fake=seg1.pors(1,0,kaf-1,l,r);
		fake+=w;
		seg1.upd(kaf+c,fake);	
		fake=seg2.pors(1,0,kaf-1,l,r);
		fake+=w;
		seg2.upd(kaf+c,fake);
	}
	if(res>=inf){
		cout<<-1<<"\n";
	}
	else{
		cout<<res<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 33108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 33108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 33108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 33108 KB Output isn't correct
2 Halted 0 ms 0 KB -