diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2023-07-31 17:55:28 +0300 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2023-07-31 17:55:28 +0300 |
| commit | 47cb41f721c44a3e89cf09218c59a64e0b703994 (patch) | |
| tree | effdd540c8b90c63a2e62f5086615404a1ee4a60 /codeforces/YetAnotherPromotion | |
| parent | 14b6ca598cdb041b56822fae224134610b7bb345 (diff) | |
| download | competitive-programming-47cb41f721c44a3e89cf09218c59a64e0b703994.tar.xz competitive-programming-47cb41f721c44a3e89cf09218c59a64e0b703994.zip | |
Solve 3 problems from div3
Diffstat (limited to 'codeforces/YetAnotherPromotion')
| -rwxr-xr-x | codeforces/YetAnotherPromotion/main | bin | 16728 -> 16728 bytes | |||
| -rwxr-xr-x | codeforces/YetAnotherPromotion/main.cpp | 24 |
2 files changed, 8 insertions, 16 deletions
diff --git a/codeforces/YetAnotherPromotion/main b/codeforces/YetAnotherPromotion/main Binary files differindex 9b890d0..a18a652 100755 --- a/codeforces/YetAnotherPromotion/main +++ b/codeforces/YetAnotherPromotion/main diff --git a/codeforces/YetAnotherPromotion/main.cpp b/codeforces/YetAnotherPromotion/main.cpp index a772000..641c42d 100755 --- a/codeforces/YetAnotherPromotion/main.cpp +++ b/codeforces/YetAnotherPromotion/main.cpp @@ -116,27 +116,19 @@ template <typename T, typename... TS> void print(T val, TS... vals) { * DON'T GET STUCK ON ONE APPROACH */ +// 2 * x + x = 10 +// x(m + 1) = 10 + void solve() { ll a, b, n, m; cin >> a >> b >> n >> m; - if (m >= n) { - cout << min(a, b) * n << '\n'; - return; - } ll ans = 0; - if (m < n) { - if ((a * m) / (m + 1) <= b) { - ans += (n * m / (m + 1)) * a; - int x = (n * m / (m + 1)); - n -= x + x / m; - } else { - ans += b * n; - n = 0; - } - } - if (n == 1) { - ans += min(a, b); + ll rem = n; + if (a * m <= b * (m + 1)) { + ans += a * m * (n / (m + 1)); + rem = n % (m + 1); } + ans += rem * min(a, b); cout << ans << '\n'; } |
