diff --git a/18xxx/18130.cpp b/18xxx/18130.cpp new file mode 100644 index 00000000..86ed08e2 --- /dev/null +++ b/18xxx/18130.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +using namespace std; + +inline long long calc(long long q, long long p, long long k, long long c) { + long long n = (q-1) / k; + return p + n * (n+1) / 2 * c; +} + +void solve(void) { + int n, q; cin >> n >> q; + + pair ans = {-1, 1e18}; + for (int i=1; i<=n; i++) { + int p, k, c; cin >> p >> k >> c; + if (calc(q, p, k, c) < ans.second) { + ans = {i, calc(q, p, k, c)}; + } + } + cout << ans.first << " " << ans.second; +} + +int main(void) { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + solve(); + return 0; +} \ No newline at end of file