Submission #129759

# Submission time Handle Problem Language Result Execution time Memory
129759 2019-07-13T07:25:25 Z 윤교준(#3140) 도장 모으기 (JOI14_stamps) C++14
85 / 100
4 ms 604 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;

			upmin(ret, dp[i-1][j] + A[i] + B[i] + ll(2*j+1) * T);
			if(1 < i) {
				for(int d = 1; d <= N-j; d++)
					upmin(ret, dp[i-1][j+d] + ll(d) * (A[i]+D[i]) + ll(T)*(2*j + 2*d+1));
			}
			for(int t = 1; t <= j; t++)
				upmin(ret, dp[i-1][j-t] + ll(t) * (B[i]+C[i]) + ll(T) * (2*j-2*t+1));
			if(1 < i && j) upmin(ret, dp[i-1][j] + C[i] + D[i] + ll(T) * (2*j+1));
		}
	}
	
	cout << dp[N][0] + T << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 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 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 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 4 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 3 ms 376 KB Output is correct
8 Correct 4 ms 504 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 604 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -