Submission #156047

# Submission time Handle Problem Language Result Execution time Memory
156047 2019-10-03T02:30:22 Z puppies_and_rainbows 도장 모으기 (JOI14_stamps) C++14
100 / 100
175 ms 71268 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n, t, dp[3005][3005];
int u[3005], v[3005], d[3005], e[3005];

signed main()
{
	cin>>n>>t;
	for(int i=0; i<=n; i++)
	{
		dp[0][i]=100000000000000;
	}
	dp[0][1]=0;
	for(int i=1; i<=n; i++)
	{
		cin>>u[i]>>v[i]>>d[i]>>e[i];
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			if(j==1)
			{
				dp[i][j]=dp[i-1][j]+u[i]+v[i];
			}
			else
			{
				dp[i][j]=dp[i-1][j]+min(u[i]+v[i], d[i]+e[i]);
			}
		}
		int tomin[3005];
		tomin[0]=1000000000000000;
		tomin[n+1]=1000000000000000;
		for(int j=1; j<=n; j++)
		{
			tomin[j]=min(tomin[j-1], dp[i-1][j]-j*(v[i]+d[i]));
		}
		for(int j=1; j<=n; j++)
		{
			dp[i][j]=min(dp[i][j], tomin[j-1]+j*(v[i]+d[i]));
		}
		for(int j=n; j>=1; j--)
		{
			tomin[j]=min(tomin[j+1], dp[i-1][j]+j*(u[i]+e[i]));
		}
		for(int j=1; j<=n; j++)
		{
			dp[i][j]=min(dp[i][j], tomin[j+1]-j*(u[i]+e[i]));
		}
		for(int j=1; j<=n; j++)
		{
			dp[i][j]+=(2*j-1)*t;
		}
		// for(int j=1; j<=4; j++)
		// {
		// 	cout<<dp[i][j]<<" ";
		// }
		// cout<<endl;
	}
	cout<<dp[n][1]+t;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 888 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 636 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 3 ms 888 KB Output is correct
9 Correct 3 ms 888 KB Output is correct
10 Correct 3 ms 792 KB Output is correct
11 Correct 3 ms 888 KB Output is correct
12 Correct 3 ms 888 KB Output is correct
13 Correct 3 ms 888 KB Output is correct
14 Correct 3 ms 888 KB Output is correct
15 Correct 3 ms 888 KB Output is correct
16 Correct 11 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 175 ms 70992 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 162 ms 71172 KB Output is correct
4 Correct 139 ms 62840 KB Output is correct
5 Correct 104 ms 51956 KB Output is correct
6 Correct 48 ms 24312 KB Output is correct
7 Correct 30 ms 15284 KB Output is correct
8 Correct 159 ms 71268 KB Output is correct
9 Correct 158 ms 71084 KB Output is correct
10 Correct 158 ms 71048 KB Output is correct
11 Correct 161 ms 71160 KB Output is correct
12 Correct 166 ms 71188 KB Output is correct
13 Correct 160 ms 71100 KB Output is correct
14 Correct 158 ms 71160 KB Output is correct
15 Correct 168 ms 71036 KB Output is correct
16 Correct 168 ms 71168 KB Output is correct
17 Correct 168 ms 71176 KB Output is correct