Submission #602493

# Submission time Handle Problem Language Result Execution time Memory
602493 2022-07-23T07:05:20 Z HamletPetrosyan Sightseeing in Kyoto (JOI22_kyoto) C++17
10 / 100
10 ms 12244 KB
/// #if (code == true)

#include <bits/stdc++.h>
using namespace std;

#define pll pair<long long, long long>
#define len(a) ((int)((a).size()))
#define all(a) a.begin(), a.end()
#define add push_back
#define mkp make_pair
#define ll long long
#define fr first
#define sc second

const long long INF = 1000000000ll * 1000000003ll;
const long long MOD = 1000000007ll;
const int N = 2e5 + 5;

ll h, w, a[N], b[N];
ll cnt[N], dp[2005][2005];

void solve(){
	cin >> h >> w;
	for(int i = 1; i <= h; i++){
		cin >> a[i];
	}
	for(int i = 1; i <= w; i++){
		cin >> b[i];
	}
	for(int i = 1; i <= max(w, h); i++){
		dp[0][i] = dp[i][0] = INF;
	}

	if(h <= 1000 && w <= 1000){
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				if(i == j && i == 1) continue;
				dp[i][j] = min(dp[i - 1][j] + b[j], dp[i][j - 1] + a[i]);
			}
		}
		cout << dp[h][w] << "\n";
		return;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int _ = 1;
	// cout << fixed;
	// cout.precision(15);

	// cin >> _ ;
	while(_--) solve();
	return 0;
}

/// #else
/// #include <bits/stdc++.h> using namespace std; int main() { cout << "Hello World!"; }
/// #endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 3 ms 4648 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 332 KB Output is correct
9 Correct 10 ms 12192 KB Output is correct
10 Correct 9 ms 12244 KB Output is correct
11 Correct 10 ms 12148 KB Output is correct
12 Correct 9 ms 12116 KB Output is correct
13 Correct 9 ms 12172 KB Output is correct
14 Correct 9 ms 12120 KB Output is correct
15 Correct 9 ms 12116 KB Output is correct
16 Correct 9 ms 12116 KB Output is correct
17 Correct 9 ms 12124 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 2 ms 5460 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 3 ms 4648 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 332 KB Output is correct
9 Correct 10 ms 12192 KB Output is correct
10 Correct 9 ms 12244 KB Output is correct
11 Correct 10 ms 12148 KB Output is correct
12 Correct 9 ms 12116 KB Output is correct
13 Correct 9 ms 12172 KB Output is correct
14 Correct 9 ms 12120 KB Output is correct
15 Correct 9 ms 12116 KB Output is correct
16 Correct 9 ms 12116 KB Output is correct
17 Correct 9 ms 12124 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Incorrect 2 ms 5460 KB Output isn't correct
32 Halted 0 ms 0 KB -