90632024-02-13 14:48:16RRoliBenzinkút üzemeltetés (55)cpp17Runtime error 6/554ms3152 KiB
#include <iostream>

using namespace std;

struct{
    long long hely;
    long long hasz;
} a[1000];
long long n, k, L[1000], maxi, kov[1000];

int main()
{
    cin >> n >> k;
    for(long long i = 1; i <= n; i++) {
       cin >> a[i].hely >> a[i].hasz;
       kov[i] = -1;
    }

    for(long long i = n; i >= 1; i--) {
        L[i] = a[i].hasz;
        long long ln = 0;
        for(long long j = i+1; j <= n; j++) {
            if(a[j].hely - a[i].hely >= k && L[j] > ln) {
                ln = L[j];
                kov[i] = j;
            }
        }
        L[i] += ln;
        if(maxi < L[i])
            maxi = L[i];
    }

    cout << maxi << endl;
    long long t = 1, jo[1000];
    for(long long i = 1; i <= n; i++)
        if(L[i] == maxi) {
            jo[1] = i;
            while(kov[i] != -1) {
                t++;
                jo[i] = kov[i];
                i = kov[i];
            }
            break;
        }
    cout << t << ' ';
    for(long long i = 1; i <= t; i++)
        cout << jo[i] << ' ';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/55
1Accepted0/03ms1892 KiB
2Runtime error0/04ms2132 KiB
3Wrong answer0/32ms2096 KiB
4Wrong answer0/33ms2096 KiB
5Accepted3/33ms2224 KiB
6Wrong answer0/33ms2400 KiB
7Accepted3/33ms2612 KiB
8Wrong answer0/32ms2692 KiB
9Wrong answer0/33ms2964 KiB
10Wrong answer0/33ms2828 KiB
11Wrong answer0/33ms2772 KiB
12Wrong answer0/33ms2920 KiB
13Wrong answer0/43ms2932 KiB
14Wrong answer0/44ms3060 KiB
15Wrong answer0/54ms3148 KiB
16Wrong answer0/64ms3152 KiB
17Wrong answer0/64ms3148 KiB