From b81a64629c5afeec356947745e5f85623cfdecfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Sun, 17 Dec 2023 09:07:35 +0800 Subject: [PATCH] 'commit' --- TangDou/Topic/PrefixAndSuffix/P3406.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/TangDou/Topic/PrefixAndSuffix/P3406.cpp b/TangDou/Topic/PrefixAndSuffix/P3406.cpp index 23ccdfb..26a6f57 100644 --- a/TangDou/Topic/PrefixAndSuffix/P3406.cpp +++ b/TangDou/Topic/PrefixAndSuffix/P3406.cpp @@ -10,11 +10,10 @@ int a[N], b[N], c[N], x, y; // 用于记录每段路径所花的费用 signed main() { cin >> n >> m; - for (int i = 1; i <= m; i++) - scanf("%lld", &p[i]); - for (int i = 1; i <= n - 1; i++) - scanf("%lld%lld%lld", &a[i], &b[i], &c[i]); - for (int i = 1; i <= m - 1; i++) { // 所有的区间都以较小的点排在前面,例如:2-1,5-3都用1-2,3-5表示,且每一段都用前面较小的点作为标记!!!! + for (int i = 1; i <= m; i++) cin >> p[i]; + for (int i = 1; i < n; i++) cin >> a[i] >> b[i] >> c[i]; + + for (int i = 1; i < m; i++) { // 所有的区间都以较小的点排在前面,例如:2-1,5-3都用1-2,3-5表示,且每一段都用前面较小的点作为标记!!!! if (p[i] > p[i + 1]) { x = p[i + 1]; y = p[i]; @@ -30,5 +29,5 @@ signed main() { } for (int i = 1; i <= n - 1; i++) ans += min(a[i] * t[i], (b[i] * t[i] + c[i])); // 求总的最小就是把每一段的最小相加 - printf("%lld", ans); + cout << ans << endl; } \ No newline at end of file