답안 #163197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163197 2019-11-11T18:01:43 Z TadijaSebez 도장 모으기 (JOI14_stamps) C++11
100 / 100
199 ms 72184 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=3050;
const ll inf=3e18;
ll dp[N][N];
int U[N],V[N],D[N],E[N];
int main()
{
	int n,t;
	scanf("%i %i",&n,&t);
	for(int i=1;i<=n;i++) scanf("%i %i %i %i",&U[i],&V[i],&D[i],&E[i]);
	dp[0][0]=0;
	for(int i=1;i<=n;i++) dp[0][i]=inf;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j]=inf;
			if(j!=0) dp[i][j]=min(dp[i][j],dp[i-1][j-1]+D[i]+V[i]-t*i*2);
			if(j!=n) dp[i][j]=min(dp[i][j],dp[i-1][j+1]+U[i]+E[i]+t*i*2);
			dp[i][j]=min(dp[i][j],dp[i-1][j]+U[i]+V[i]);
			if(j!=0) dp[i][j]=min(dp[i][j],dp[i-1][j]+D[i]+E[i]);
		}
		for(int j=1;j<=n;j++) dp[i][j]=min(dp[i][j],dp[i][j-1]+D[i]+V[i]-t*i*2);
		for(int j=n-1;j>=1;j--) dp[i][j]=min(dp[i][j],dp[i][j+1]+U[i]+E[i]+t*i*2);
	}
	ll ans=dp[n][0]+(n+1)*t;
	printf("%lld\n",ans);
	return 0;
}

Compilation message

stamps.cpp: In function 'int main()':
stamps.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&t);
  ~~~~~^~~~~~~~~~~~~~~
stamps.cpp:12:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%i %i %i %i",&U[i],&V[i],&D[i],&E[i]);
                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 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 376 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 5 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 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 376 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 376 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 12 ms 760 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 3 ms 760 KB Output is correct
12 Correct 3 ms 892 KB Output is correct
13 Correct 3 ms 888 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
15 Correct 3 ms 888 KB Output is correct
16 Correct 3 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 181 ms 71928 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 182 ms 72184 KB Output is correct
4 Correct 146 ms 63756 KB Output is correct
5 Correct 118 ms 51960 KB Output is correct
6 Correct 53 ms 24248 KB Output is correct
7 Correct 32 ms 15352 KB Output is correct
8 Correct 193 ms 72032 KB Output is correct
9 Correct 190 ms 72056 KB Output is correct
10 Correct 199 ms 72044 KB Output is correct
11 Correct 179 ms 72036 KB Output is correct
12 Correct 180 ms 72072 KB Output is correct
13 Correct 181 ms 72092 KB Output is correct
14 Correct 179 ms 72072 KB Output is correct
15 Correct 177 ms 72060 KB Output is correct
16 Correct 195 ms 72072 KB Output is correct
17 Correct 179 ms 72156 KB Output is correct