30142023-02-08 11:34:371478Szörnyekcpp17Wrong answer 0/1001.1s7268 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
1Accepted3ms1684 KiB
2Accepted3ms1932 KiB
subtask20/13
3Accepted3ms1936 KiB
4Wrong answer3ms2056 KiB
5Wrong answer3ms2260 KiB
6Wrong answer3ms2484 KiB
subtask30/22
7Wrong answer3ms2688 KiB
8Wrong answer3ms2904 KiB
9Wrong answer3ms3036 KiB
10Wrong answer3ms2992 KiB
11Wrong answer3ms3116 KiB
12Wrong answer3ms3240 KiB
13Wrong answer3ms3368 KiB
14Wrong answer3ms3452 KiB
subtask40/65
15Time limit exceeded1.1s4400 KiB
16Wrong answer310ms6656 KiB
17Time limit exceeded1.08s4756 KiB
18Wrong answer83ms6744 KiB
19Wrong answer82ms6744 KiB
20Wrong answer83ms7056 KiB
21Wrong answer82ms6944 KiB
22Wrong answer82ms7268 KiB
23Wrong answer81ms7160 KiB
24Wrong answer81ms7160 KiB