• LQDOJ
  • Trang chủ
  • Bài tập
  • Bài nộp
  • Thành viên
  • Kỳ thi
  • Nhóm
  • Giới thiệu
    • Status
    • Khóa học
    • Đề xuất ý tưởng
    • Proposal Problem
    • Proposal Contest
    • Tools
    • Báo cáo tiêu cực
    • Báo cáo lỗi

Tiếng Việt

Tiếng Việt
English

Đăng nhập

Đăng ký

ThuanPhat

  • Giới thiệu
  • Bài tập
  • Bài nộp

Rating
-
Bài tập
1
Điểm
1301
Rating #
-
Điểm #
28776

Giới thiệu

include <bits/stdc++.h>

using namespace std;

define ll long long

define F(i, a, b) for(ll i = a; i <= b; ++i)

define Fo(i, a, b) for(ll i = a; i >= b; --i)

define sz(s) (s).size()

define SIZE 1007

define oo 10000

define fase ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef vector<ll> vti;

ll m, n, a[SIZE][SIZE], dp[SIZE][SIZE];

ll min(ll a, ll b) {
return a > b ? b : a;
}

void getIn() {
cin >> m >> n;
F(i, 1, m) F(j, 1, n) cin >> a[i][j];
F(i, 1, m) dp[i][0] = dp[i][m+1] = oo;
F(i, 1, n) dp[0][i] = dp[n+1][i] = oo;
}

void solve() {
freopen("DUONGDI.INP", "r", stdin);
freopen("DUONGDI.OUT", "w", stdout);
getIn();
F(i, 1, m) {
F(j, 1, n) {
if (i == 1 && j == 1)
dp[i][j] = a[i][j];
else
dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + a[i][j];
}
}
cout << dp[m][n];
}

signed main() {
int t = 1;
while(t--) solve();
}


«    »
Thứ 2
Thứ 3
Thứ 4
Thứ 5
Thứ 6
Thứ 7
CN
Ít
Nhiều

proudly powered by DMOJ| developed by LQDJudge team