From 217e981c00dfa7ca7cf1ca8798fa1beec9964359 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Wed, 23 Jul 2025 10:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=8F=98=E9=87=8F=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=BB=8E=20int=20=E6=9B=B4=E6=94=B9=E4=B8=BA=20ll=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E6=9B=B4=E5=A4=A7=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E5=80=BC=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/7/23/T637676d.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/7/23/T637676d.cpp b/src/7/23/T637676d.cpp index b050570..136fb0c 100644 --- a/src/7/23/T637676d.cpp +++ b/src/7/23/T637676d.cpp @@ -1,44 +1,47 @@ +#include #include #include #include + +using ll = int64_t; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); - int n, m, k; + ll n, m, k; cin >> n >> m >> k; vector v(n); - for (int i = 0; i < n; i++) { + for (ll i = 0; i < n; i++) { cin >> v[i]; } - vector dp(k + 1, 1e9); + vector dp(k + 1, 1e9); dp[0] = 0; - for (int i = 0; i < n; i++) { - vector a; - for (int j = 0; j < m; j++) { + for (ll i = 0; i < n; i++) { + vector a; + for (ll j = 0; j < m; j++) { if (v[i][j] == '1') { a.push_back(j); } } - int p = a.size(); - vector f(p + 1, 0); + ll p = a.size(); + vector f(p + 1, 0); if (p == 0) { - vector ndp = dp; + vector ndp = dp; dp = move(ndp); continue; } f[p] = 0; - for (int t = 0; t < p; t++) { - int b = p - 1 - t; - int mval = 1e9; - for (int x = 0; x <= t; x++) { - int cost = a[b + x] - a[x] + 1; + for (ll t = 0; t < p; t++) { + ll b = p - 1 - t; + ll mval = 1e9; + for (ll x = 0; x <= t; x++) { + ll cost = a[b + x] - a[x] + 1; if (cost < mval) { mval = cost; } @@ -46,9 +49,9 @@ int main() { f[t] = mval; } - vector ndp(k + 1, 1e9); - for (int j = 0; j <= k; j++) { - for (int t = 0; t <= min(p, j); t++) { + vector ndp(k + 1, 1e9); + for (ll j = 0; j <= k; j++) { + for (ll t = 0; t <= min(p, j); t++) { if (dp[j - t] != 1e9) { if (dp[j - t] + f[t] < ndp[j]) { ndp[j] = dp[j - t] + f[t]; @@ -59,7 +62,7 @@ int main() { dp = move(ndp); } - int ans = *min_element(dp.begin(), dp.end()); + ll ans = *min_element(dp.begin(), dp.end()); cout << ans << endl; return 0;