228902026-01-16 07:35:20badamBenzinkút üzemeltetés (55)cpp17Wrong answer 26/552ms508 KiB
#include <bits/stdc++.h>

using namespace std;
struct hely
{
    int tav, haszon;
};
int main()
{   ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, szamlalo=0;
    cin>>n>>k;
    hely t[n+1];
    t[0].haszon=0;
    t[0].tav=-2e9;
    int veg=0;
    for(int i=1; i<=n; i++) cin>>t[i].tav>>t[i].haszon;
    int maxi[n+1], jelenlegi_max=0;
    maxi[0]=0;
    for(int i=1; i<n; i++) maxi[i]=0;
    vector <bool> v(n+1,false);
    vector <int> v1(n+1,0);
    for(int i=1; i<=n; i++)
    {
        int j=0;
        while(t[i].tav-t[j].tav>=k)
        {
            int most_haszon=t[i].haszon+maxi[j];
            if(most_haszon>maxi[i]) maxi[i]=most_haszon, v1[i]=j;
            j++;
        }
        if(maxi[i]>jelenlegi_max)
        {
            jelenlegi_max=maxi[i];
            veg=i;
        }
    }
    cout << jelenlegi_max << endl;
    vector <int> utvonal;
    while(veg!=0)
    {
        utvonal.push_back(veg);
        veg=v1[veg];
    }
    cout << utvonal.size() << " ";
    sort(utvonal.begin(),utvonal.end());
    for(int x:utvonal)cout<<x<<" ";


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base26/55
1Wrong answer0/01ms316 KiB
2Accepted0/02ms316 KiB
3Wrong answer0/31ms508 KiB
4Wrong answer0/31ms316 KiB
5Accepted3/31ms316 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/31ms316 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/31ms316 KiB
11Wrong answer0/31ms316 KiB
12Accepted3/31ms316 KiB
13Accepted4/41ms316 KiB
14Accepted4/41ms428 KiB
15Wrong answer0/51ms316 KiB
16Accepted6/61ms316 KiB
17Accepted6/62ms316 KiB