90982024-02-13 21:48:49RRoliBenzinkút üzemeltetés (55)cpp17Accepted 55/554ms3704 KiB
#include <bits/stdc++.h>
using namespace std;

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

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[1001];
    for(long long i = 1; i <= n; i++)
        if(L[i] == maxi) {
            jo[1] = i;
            while(kov[i] != -1) {
                t++;
                jo[t] = kov[i];
                i = kov[i];
            }
            break;
        }
    cout << t << ' ';
    for(long long i = 1; i <= t; i++)
        cout << jo[i] << ' ';

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/03ms1888 KiB
2Accepted0/04ms2272 KiB
3Accepted3/33ms2316 KiB
4Accepted3/33ms2392 KiB
5Accepted3/33ms2604 KiB
6Accepted3/33ms2844 KiB
7Accepted3/33ms3036 KiB
8Accepted3/32ms3112 KiB
9Accepted3/33ms3240 KiB
10Accepted3/33ms3452 KiB
11Accepted3/33ms3540 KiB
12Accepted3/33ms3704 KiB
13Accepted4/43ms3556 KiB
14Accepted4/44ms3556 KiB
15Accepted5/54ms3556 KiB
16Accepted6/64ms3556 KiB
17Accepted6/64ms3560 KiB