提交时间:2024-05-25 15:41:06

运行 ID: 149040

#include <bits/stdc++.h> using namespace std; const int N = 110; int a[N] , sum[N] , b[N]; int f[N]; int main(){ int n; cin >> n; for (int i = 1, a; i <= n; i++){ cin >> a[i] >> b[i]; sum[i] = sum[i - 1] + a[i]; } for (int i = 1; i <= n; i++){ f[i] = 1e9; for (int j = 0; j < i; j++) f[i] = min(f[i], f[j] + (sum[i] - sum[j] + 10) * b[i]); } cout << f[n] << endl; return 0; }