77592024-01-11 08:09:33BenedekMartonBenzinkút üzemeltetés (55)cpp17Wrong answer 15/553ms3448 KiB
#include <iostream>
#include <algorithm>

using namespace std;

struct isz
{
    int ind;
    int sz;
};
bool f(isz a, isz b)
{
    return a.sz<b.sz;
}

int main()
{
    int n, k, oh=0, bsz=0;
    cin >> n >> k;
    int t[n], h[n];
    isz rh[n];
    bool sze[n];
    for(int i=0; i<n; i++)
    {
        cin >> t[i] >> h[i];
        sze[i]=1;
    }
    for(int i=0; i<n; i++)
    {
        rh[i].sz=h[i];
        rh[i].ind=i;
        for(int j=i-1; t[i]-t[j]<k and j>=0; j--)
        {
            rh[i].sz=rh[i].sz-h[j];
        }
        for(int j=i+1; t[j]-t[i]<k and j<n; j++)
        {
            rh[i].sz=rh[i].sz-h[j];
        }
    }
    sort(rh, rh+n, f);
    for(int i=n-1; i>=0; i--)
    {
        if(sze[rh[i].ind])
        {
            oh=oh+h[rh[i].ind];
            bsz++;
            for(int j=rh[i].ind-1; t[rh[i].ind]-t[j]<k and j>=0; j--)
            {
                sze[j]=0;
            }
            for(int j=rh[i].ind+1; t[j]-t[rh[i].ind]<k and j<n; j++)
            {
                sze[j]=0;
            }
        }
    }
    cout << oh << endl << bsz;
    /*for(int i=0; i<n; i++)
    {
        cout << i << " " << sze[i] << endl;
    }*/
    for(int i=0; i<n; i++)
    {
        if(sze[i])
        {
            cout << " " << i+1;
        }
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base15/55
1Accepted0/03ms1884 KiB
2Wrong answer0/03ms2132 KiB
3Accepted3/33ms2276 KiB
4Accepted3/33ms2488 KiB
5Wrong answer0/33ms2700 KiB
6Accepted3/33ms2792 KiB
7Accepted3/33ms2792 KiB
8Accepted3/33ms2916 KiB
9Wrong answer0/33ms3000 KiB
10Wrong answer0/33ms3244 KiB
11Wrong answer0/33ms3220 KiB
12Wrong answer0/33ms3224 KiB
13Wrong answer0/43ms3356 KiB
14Wrong answer0/43ms3448 KiB
15Wrong answer0/53ms3440 KiB
16Wrong answer0/63ms3444 KiB
17Wrong answer0/63ms3444 KiB