30132023-02-08 11:33:551478Szörnyekcpp17Runtime error 0/1003ms4436 KiB
#include <bits/stdc++.h>

using namespace std;

struct Szorny{

    long long int elet, sebzes;

};

bool rendez(Szorny sz1, Szorny sz2){

    double x1 = double(sz1.sebzes) / double(sz1.elet);
    double x2 = double(sz2.sebzes) / double(sz2.elet);

    return (x1 >= x2);

}

bool rendez1(Szorny sz1, Szorny sz2){

    return (sz1.sebzes <= sz2.sebzes);

}

int main()
{
    ifstream cin("elod.txt");

    long long int n, p, sum = 0, index = 1, megoldas = 0;

    cin >> n >> p;

    vector<Szorny> sz(n + 1);

    for(long long int i = 1; i <= n; i++){
        cin >> sz[i].elet >> sz[i].sebzes;
        sum += sz[i].sebzes;
    }

    sort(sz.begin(), sz.end(), rendez);

    sz[1].elet -= p;


    if(sz[1].elet <= 0){
        index++;
        sum -= sz[1].sebzes;
    }

    while(index != n + 1){

        megoldas += ceil(sz[index].elet / p) * sum;


        sum -= sz[index].sebzes;

        index++;

    }

    cout << megoldas;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error3ms1840 KiB
2Runtime error3ms2116 KiB
subtask20/13
3Runtime error3ms2312 KiB
4Runtime error3ms2676 KiB
5Runtime error3ms2700 KiB
6Runtime error3ms2836 KiB
subtask30/22
7Runtime error3ms3120 KiB
8Runtime error3ms3148 KiB
9Runtime error3ms3156 KiB
10Runtime error3ms3340 KiB
11Runtime error3ms3208 KiB
12Runtime error3ms3488 KiB
13Runtime error3ms3760 KiB
14Runtime error3ms3768 KiB
subtask40/65
15Runtime error3ms3820 KiB
16Runtime error3ms3820 KiB
17Runtime error3ms4068 KiB
18Runtime error3ms4096 KiB
19Runtime error3ms4124 KiB
20Runtime error3ms4220 KiB
21Runtime error3ms4436 KiB
22Runtime error3ms4384 KiB
23Runtime error3ms4388 KiB
24Runtime error3ms4384 KiB