답안 #556887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556887 2022-05-04T09:56:36 Z DanShaders Sightseeing in Kyoto (JOI22_kyoto) C++17
10 / 100
121 ms 69684 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

namespace x = __gnu_pbds;
template <typename T>
using ordered_set = x::tree<T, x::null_type, less<T>, x::rb_tree_tag, x::tree_order_statistics_node_update>;

template <typename T>
using normal_queue = priority_queue<T, vector<T>, greater<>>;

#define all(x) begin(x), end(x)
#define sz(x) ((int) (x).size())
#define x first
#define y second
using ll = long long;
using ld = long double;

#define int ll

const int N = 1e5 + 10, M = 2e3 + 10, INF = 0x3f3f3f3f3f3f3f3f;

int suff[N];

int eliminate(int *a, int n, pair<int, int> *b) {
	suff[n] = +INF;
	for (int i = n; i--; ) {
		suff[i] = min(suff[i + 1], a[i]);
	}
	int mn = +INF, m = 0;
	for (int i = 0; i < n; ++i) {
		if (mn <= a[i] && suff[i + 1] <= a[i]) {
			continue;
		}
		b[m++] = {a[i], i};
	}
	return m;
}

int a[N], b[N];
pair<int, int> c[M], d[M];
int dp[M][M];

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	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];
	}
	n = eliminate(a, n, c);
	m = eliminate(b, m, d);

	fill(dp[0], dp[M], +INF);
	dp[0][0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + d[j].x * (c[i + 1].y - c[i].y));
			dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + c[i].x * (d[j + 1].y - d[j].y));
		}
	}
	cout << dp[n - 1][m - 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 31956 KB Output is correct
2 Correct 14 ms 31956 KB Output is correct
3 Correct 12 ms 31956 KB Output is correct
4 Correct 13 ms 31956 KB Output is correct
5 Correct 13 ms 31956 KB Output is correct
6 Correct 12 ms 31956 KB Output is correct
7 Correct 14 ms 31912 KB Output is correct
8 Correct 15 ms 31956 KB Output is correct
9 Correct 17 ms 31964 KB Output is correct
10 Correct 18 ms 31956 KB Output is correct
11 Correct 19 ms 32084 KB Output is correct
12 Correct 18 ms 31952 KB Output is correct
13 Correct 17 ms 31956 KB Output is correct
14 Correct 18 ms 31980 KB Output is correct
15 Correct 17 ms 31956 KB Output is correct
16 Correct 20 ms 32008 KB Output is correct
17 Correct 17 ms 31980 KB Output is correct
18 Correct 14 ms 31892 KB Output is correct
19 Correct 14 ms 31904 KB Output is correct
20 Correct 13 ms 31948 KB Output is correct
21 Correct 13 ms 31940 KB Output is correct
22 Correct 15 ms 31956 KB Output is correct
23 Correct 14 ms 31896 KB Output is correct
24 Correct 15 ms 31932 KB Output is correct
25 Correct 18 ms 31956 KB Output is correct
26 Correct 15 ms 31872 KB Output is correct
27 Correct 14 ms 31876 KB Output is correct
28 Correct 14 ms 31952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31936 KB Output is correct
2 Correct 14 ms 31976 KB Output is correct
3 Correct 15 ms 32036 KB Output is correct
4 Runtime error 121 ms 69684 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 31956 KB Output is correct
2 Correct 14 ms 31956 KB Output is correct
3 Correct 12 ms 31956 KB Output is correct
4 Correct 13 ms 31956 KB Output is correct
5 Correct 13 ms 31956 KB Output is correct
6 Correct 12 ms 31956 KB Output is correct
7 Correct 14 ms 31912 KB Output is correct
8 Correct 15 ms 31956 KB Output is correct
9 Correct 17 ms 31964 KB Output is correct
10 Correct 18 ms 31956 KB Output is correct
11 Correct 19 ms 32084 KB Output is correct
12 Correct 18 ms 31952 KB Output is correct
13 Correct 17 ms 31956 KB Output is correct
14 Correct 18 ms 31980 KB Output is correct
15 Correct 17 ms 31956 KB Output is correct
16 Correct 20 ms 32008 KB Output is correct
17 Correct 17 ms 31980 KB Output is correct
18 Correct 14 ms 31892 KB Output is correct
19 Correct 14 ms 31904 KB Output is correct
20 Correct 13 ms 31948 KB Output is correct
21 Correct 13 ms 31940 KB Output is correct
22 Correct 15 ms 31956 KB Output is correct
23 Correct 14 ms 31896 KB Output is correct
24 Correct 15 ms 31932 KB Output is correct
25 Correct 18 ms 31956 KB Output is correct
26 Correct 15 ms 31872 KB Output is correct
27 Correct 14 ms 31876 KB Output is correct
28 Correct 14 ms 31952 KB Output is correct
29 Correct 13 ms 31936 KB Output is correct
30 Correct 14 ms 31976 KB Output is correct
31 Correct 15 ms 32036 KB Output is correct
32 Runtime error 121 ms 69684 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -