답안 #884858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884858 2023-12-08T14:55:08 Z MinaRagy06 Sightseeing in Kyoto (JOI22_kyoto) C++17
10 / 100
697 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int di[2] = {0, 1};
int dj[2] = {1, 0};
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	ll dist[n][m], a[n], b[m];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			dist[i][j] = 1e18;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	auto valid = [&] (int i, int j) {
		return i < n && j < m;
	};
	dist[0][0] = 0;
	priority_queue<array<ll, 3>> pq;
	pq.push({0, 0, 0});
	while (pq.size()) {
		auto [c, i, j] = pq.top();
		pq.pop();
		c *= -1;
		for (int k = 0; k < 2; k++) {
			ll newi = i + di[k];
			ll newj = j + dj[k];
			ll newc = c + (!di[k]) * a[i] + (!dj[k]) * b[j];
			if (valid(newi, newj) && newc < dist[newi][newj]) {
				dist[newi][newj] = newc;
				pq.push({-newc, newi, newj});
			}
		}
	}
	cout << dist[n - 1][m - 1] << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 6 ms 860 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 205 ms 11660 KB Output is correct
10 Correct 197 ms 12524 KB Output is correct
11 Correct 145 ms 8724 KB Output is correct
12 Correct 146 ms 8720 KB Output is correct
13 Correct 104 ms 8344 KB Output is correct
14 Correct 133 ms 8436 KB Output is correct
15 Correct 131 ms 8392 KB Output is correct
16 Correct 126 ms 8540 KB Output is correct
17 Correct 95 ms 8536 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 452 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 44 ms 3584 KB Output is correct
4 Runtime error 697 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 6 ms 860 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 205 ms 11660 KB Output is correct
10 Correct 197 ms 12524 KB Output is correct
11 Correct 145 ms 8724 KB Output is correct
12 Correct 146 ms 8720 KB Output is correct
13 Correct 104 ms 8344 KB Output is correct
14 Correct 133 ms 8436 KB Output is correct
15 Correct 131 ms 8392 KB Output is correct
16 Correct 126 ms 8540 KB Output is correct
17 Correct 95 ms 8536 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 452 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 44 ms 3584 KB Output is correct
32 Runtime error 697 ms 1048576 KB Execution killed with signal 9
33 Halted 0 ms 0 KB -