답안 #129755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129755 2019-07-13T07:22:23 Z 윤교준(#3140) 도장 모으기 (JOI14_stamps) C++14
85 / 100
4 ms 632 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll dp[105][105];

int A[105], B[105], C[105], D[105];

int N, T;

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> T;
	for(int i = 1; i <= N; i++)
		cin >> A[i] >> B[i] >> C[i] >> D[i];
	
	fill(dp[0], dp[N+2]+(N+2), INFLL);
	dp[0][0] = 0;

	for(int i = 1; i <= N; i++) {
		for(int j = 0; j <= N; j++) {
			ll &ret = dp[i][j];
			ret = INFLL;

			// Case 1
			upmin(ret, dp[i-1][j] + ll(j+1)*T + A[i] + B[i] + ll(j)*T);

			// Case 2
			if(1 < i) {
			for(int d = 1; j+d <= N; d++)
				upmin(ret, dp[i-1][j+d] + ll(j+d+1)*T + d * ll(A[i]+D[i]) + ll(j+d)*T);
			}

			// Case 3
			for(int t = 1; t <= j; t++)
				upmin(ret, dp[i-1][j-t] + ll(j-t+1)*T + t * ll(B[i]+C[i]) + ll(j-t)*T);

			// Case 4
			if(1 < i && j) {
			upmin(ret, dp[i-1][j] + ll(j+1)*T + C[i] + D[i] + ll(j)*T);
			}
		}
	}
	
	cout << dp[N][0] + T << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 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 348 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 376 KB Output is correct
12 Correct 2 ms 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 504 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 3 ms 376 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 4 ms 504 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 504 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 504 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 504 KB Output is correct
16 Correct 4 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -