Official
C - Heavy Snake Editorial by en_translator
If a snake with thickness \(T_i\) and length \(L_i\) extends its length by \(k\), it will have a weight \(T_i(L_i + k)\).
Thus, we can find the maximum value of \(T_i(L_i + k)\) for \(k = 1, 2, \ldots, D\).
Sample code
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, d;
cin >> n >> d;
vector<int> t(n), l(n);
for (int i = 0; i < n; i++) cin >> t[i] >> l[i];
for (int k = 1; k <= d; k++) {
int ans = 0;
for (int i = 0; i < n; i++) ans = max(ans, t[i] * (l[i] + k));
cout << ans << '\n';
}
}
posted:
last update: