36062023-03-01 10:05:20Error42Szörnyekcpp17Wrong answer 0/10074ms18248 KiB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

using ll = long long;

struct monster {
    ll attack;
    ll hits;

    bool operator <(monster const& rhs) const {
        return attack * rhs.hits < rhs.attack * hits;
    }
};

int main() {
    ll n, p;
    cin >> n >> p;

    vector<monster> monsters(n);

    for (monster& m : monsters) {
        ll a, d;
        cin >> a >> d;

        m = { a, (d + p - 1) / p };
    }

    sort(monsters.begin(), monsters.end());

    ll ans = 0;
    ll dmg = 0;

    for (monster const& m : monsters) {
        dmg += m.attack;

        ans += dmg * m.hits;
    }

    ans -= dmg;

    cout << ans << "\n";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1684 KiB
2Accepted3ms1848 KiB
subtask20/13
3Accepted3ms2196 KiB
4Wrong answer3ms2404 KiB
5Wrong answer3ms2608 KiB
6Accepted3ms2700 KiB
subtask30/22
7Accepted3ms2916 KiB
8Wrong answer3ms3248 KiB
9Accepted3ms3260 KiB
10Wrong answer3ms3100 KiB
11Wrong answer3ms3100 KiB
12Wrong answer3ms3104 KiB
13Wrong answer3ms3108 KiB
14Wrong answer3ms3352 KiB
subtask40/65
15Accepted72ms7628 KiB
16Wrong answer61ms8636 KiB
17Accepted74ms9888 KiB
18Wrong answer74ms11112 KiB
19Wrong answer74ms12344 KiB
20Wrong answer74ms13376 KiB
21Wrong answer72ms14324 KiB
22Wrong answer72ms15676 KiB
23Wrong answer71ms17024 KiB
24Wrong answer72ms18248 KiB