Official
C - Heavy Snake Editorial
by
C - Heavy Snake Editorial
by
cn449
太さが \(T_i\)、長さが \(L_i\) のヘビの長さが \(k\) 伸びたときのヘビの重さは \(T_i(L_i + k)\) です。
したがって、各 \(k = 1, 2, \ldots, D\) に対して \(T_i(L_i + k)\) の最大値を求め、出力すればよいです。
実装例
#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: