Skip to content

Commit

Permalink
Add 18130.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Aug 20, 2024
1 parent 2b4a2ed commit ea39954
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions 18xxx/18130.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
#include <utility>
#include <vector>
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<int, long long> 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;
}

0 comments on commit ea39954

Please sign in to comment.