Submission #583333

# Submission time Handle Problem Language Result Execution time Memory
583333 2022-06-25T08:47:55 Z Koosha_mv Bodyguard (JOI21_bodyguard) C++14
6 / 100
1881 ms 1470464 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=12222,M=6060;

ll n,q,T[N],A[N],B[N],C[N],dp[N][M],nxt[N][M],prv[N][M];

int32_t main(){
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n>>q;
	f(i,0,n){
		cin>>T[i]>>A[i]>>B[i]>>C[i];
		T[i]<<=1;
		A[i]<<=1;
		B[i]<<=1;
		C[i]>>=1;
		if(A[i]<B[i]){
			f(pos,A[i],B[i]){
				maxm(nxt[T[i]+pos-A[i]][pos],C[i]);
			}
		}
		else{
			f_(pos,A[i],B[i]+1){
				maxm(prv[T[i]+A[i]-pos][pos],C[i]);
			}
		}
	}
	f_(i,N-2,1){
		f(j,1,M-2){
			dp[i][j]=max(dp[i+1][j+1]+nxt[i][j],dp[i+1][j-1]+prv[i][j]);
		}
	}
	while(q--){
		int p,x;
		cin>>p>>x;
		cout<<dp[p<<1][x<<1]<<'\n';
	}
}
/*
3 1
3 1 5 2
1 4 1 4
4 2 4 4
2 2

2 1
1 2 1 4
3 1 3 2
3 3
*/
# Verdict Execution time Memory Grader output
1 Correct 1855 ms 1470464 KB Output is correct
2 Correct 1881 ms 1464336 KB Output is correct
3 Correct 1486 ms 747292 KB Output is correct
4 Correct 1489 ms 670744 KB Output is correct
5 Correct 1645 ms 873616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1855 ms 1470464 KB Output is correct
2 Correct 1881 ms 1464336 KB Output is correct
3 Correct 1486 ms 747292 KB Output is correct
4 Correct 1489 ms 670744 KB Output is correct
5 Correct 1645 ms 873616 KB Output is correct
6 Runtime error 24 ms 340 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -