30042023-02-08 08:56:02samatSzörnyekcpp11Wrong answer 0/100108ms7296 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
1Accepted3ms1816 KiB
2Wrong answer3ms2180 KiB
subtask20/13
3Wrong answer3ms2160 KiB
4Wrong answer3ms2296 KiB
5Wrong answer3ms2380 KiB
6Wrong answer3ms2620 KiB
subtask30/22
7Wrong answer3ms2848 KiB
8Wrong answer3ms2944 KiB
9Wrong answer2ms3024 KiB
10Wrong answer3ms3156 KiB
11Wrong answer3ms3236 KiB
12Wrong answer3ms3244 KiB
13Wrong answer2ms3240 KiB
14Wrong answer3ms3480 KiB
subtask40/65
15Runtime error61ms6780 KiB
16Runtime error108ms6856 KiB
17Runtime error70ms6916 KiB
18Wrong answer85ms6968 KiB
19Wrong answer85ms6928 KiB
20Wrong answer83ms7004 KiB
21Wrong answer85ms7256 KiB
22Wrong answer85ms7216 KiB
23Wrong answer82ms7296 KiB
24Wrong answer82ms7200 KiB