172992025-06-20 15:42:26MrkzBenzinkút üzemeltetés (55)cpp17Wrong answer 5/552ms564 KiB
#include <bits/stdc++.h>

using namespace std;
struct Benzinkut {
    int tav;
    int hozam;
    int index;
};
vector<Benzinkut> B;
vector<int> megoldas, helyek;
int N,K;
int main()
{
    //ifstream f("benzinkut.in");
    cin>>N>>K;
    B.resize(N);
    for(int i=0;i<N;i++){
        cin>>B[i].tav>>B[i].hozam;
        B[i].index=i+1;
    }
    /*for(int i=0;i<N;i++)
        cout<<B[i].index<<" "<<B[i].tav<<" "<<B[i].hozam<<endl;*/
    sort(B.rbegin(), B.rend(), [](const Benzinkut& a, const Benzinkut& b) {
        return a.hozam < b.hozam;
    });
    /*cout<<endl;
    for(int i=0;i<N;i++)
        cout<<B[i].index<<" "<<B[i].tav<<" "<<B[i].hozam<<endl;
    cout<<endl;*/
    megoldas.resize(N);
    helyek.resize(N);
    megoldas[0]=B[0].index;
    helyek[0]=B[0].tav;
    int x=1, teljeshozam=B[0].hozam;
    for(int i=1;i<N;i++){
        bool b=true;
        for(int j=0;j<x && b==true;j++){
            if(B[i].tav<helyek[j] && B[i].tav+K>helyek[j])
                    b=false;
            if(B[i].tav>helyek[j] && B[i].tav-K<helyek[j])
                    b=false;
        }
        if(b==true){
            megoldas[x]=B[i].index;
            helyek[x]=B[i].tav;
            teljeshozam+=B[i].hozam;
            x++;
        }
    }
    cout<<teljeshozam<<endl;
    cout<<x<<" ";
    for(int i=0;i<x;i++)
        cout<<megoldas[i]<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base5/55
1Accepted0/01ms316 KiB
2Wrong answer0/02ms316 KiB
3Partially correct1/31ms316 KiB
4Partially correct1/31ms316 KiB
5Partially correct1/31ms316 KiB
6Partially correct1/31ms316 KiB
7Partially correct1/31ms316 KiB
8Wrong answer0/31ms316 KiB
9Wrong answer0/31ms564 KiB
10Wrong answer0/31ms508 KiB
11Wrong answer0/31ms508 KiB
12Wrong answer0/31ms564 KiB
13Wrong answer0/42ms508 KiB
14Wrong answer0/42ms316 KiB
15Wrong answer0/52ms316 KiB
16Wrong answer0/62ms316 KiB
17Wrong answer0/62ms316 KiB