답안 #560854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
560854 2022-05-12T03:55:10 Z 8e7 Sightseeing in Kyoto (JOI22_kyoto) C++17
10 / 100
11 ms 8232 KB
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 1005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
const ll inf = 1LL<<60;
ll dp[maxn][maxn], a[maxn], b[maxn];
int main() {
	io
	int n, m;
	cin >> n >> m;
	for (int i = 0;i < n;i++) cin >> a[i];	
	for (int i = 0;i < m;i++) cin >> b[i];	
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) dp[i][j] = inf;
	}
	dp[0][0] = 0;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) {
			if (i == 0 && j == 0) continue;
			if (i) dp[i][j] = min(dp[i][j], dp[i-1][j] + b[j]);
			if (j) dp[i][j] = min(dp[i][j], dp[i][j-1] + a[i]);
		}
	}
	cout << dp[n-1][m-1] << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 9 ms 8228 KB Output is correct
10 Correct 10 ms 8228 KB Output is correct
11 Correct 11 ms 8148 KB Output is correct
12 Correct 9 ms 8124 KB Output is correct
13 Correct 8 ms 8228 KB Output is correct
14 Correct 8 ms 8148 KB Output is correct
15 Correct 8 ms 8148 KB Output is correct
16 Correct 10 ms 8232 KB Output is correct
17 Correct 11 ms 8220 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 6 ms 2760 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 720 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 9 ms 8228 KB Output is correct
10 Correct 10 ms 8228 KB Output is correct
11 Correct 11 ms 8148 KB Output is correct
12 Correct 9 ms 8124 KB Output is correct
13 Correct 8 ms 8228 KB Output is correct
14 Correct 8 ms 8148 KB Output is correct
15 Correct 8 ms 8148 KB Output is correct
16 Correct 10 ms 8232 KB Output is correct
17 Correct 11 ms 8220 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Incorrect 6 ms 2760 KB Output isn't correct
32 Halted 0 ms 0 KB -