30122023-02-08 11:32:521478Szörnyekcpp17Wrong answer 0/1001.1s7084 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);

    for(int i = 1; i <= n; i++){
        cout << sz[i].elet << " " << sz[i].sebzes << "\n";
    }

    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
1Wrong answer3ms1816 KiB
2Wrong answer3ms2140 KiB
subtask20/13
3Wrong answer3ms2224 KiB
4Wrong answer3ms2468 KiB
5Wrong answer3ms2680 KiB
6Wrong answer3ms2584 KiB
subtask30/22
7Wrong answer3ms2952 KiB
8Wrong answer3ms2984 KiB
9Wrong answer3ms2808 KiB
10Wrong answer3ms3044 KiB
11Wrong answer2ms3132 KiB
12Wrong answer3ms3276 KiB
13Wrong answer3ms3328 KiB
14Wrong answer3ms3428 KiB
subtask40/65
15Time limit exceeded1.1s4392 KiB
16Wrong answer333ms6588 KiB
17Time limit exceeded1.065s4504 KiB
18Wrong answer107ms6760 KiB
19Wrong answer107ms6696 KiB
20Wrong answer108ms6764 KiB
21Wrong answer107ms6892 KiB
22Wrong answer107ms7084 KiB
23Wrong answer104ms6872 KiB
24Wrong answer104ms6964 KiB