44742023-03-28 12:49:48gyjazminTűzijátékcpp11Runtime error 12/50370ms64848 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    int S;
    int T;
    cin >> N >> S >> T;
    vector<int> tavok(N+1);
    for (int i=1; i<N+1;i++){
        cin >> tavok[i];
    }
    vector<vector<int>> telepulesek(N+1);
    if (S!=1){
        telepulesek[1].push_back(1);
        for ( int i=2; i<S;i++){
            telepulesek[i].push_back(i);
            int maxe=0;
            int maxi=i;
            for (int j=i-1;j>0;j--){
                if (tavok[i]-tavok[j]>=T){
                    if(telepulesek[j].size()>maxe){
                    maxe= telepulesek[j].size();
                    maxi = j;
                    }

                }
            }
            if(maxe>0){
                for(int x : telepulesek[maxi]){
                    telepulesek[i].push_back(x);
                }
            }
        }
        int maxi=0;
        for (int i=1; i<S;i++){
            if (tavok[S]-tavok[i]>=T){
                if (telepulesek[i].size()>telepulesek[maxi].size()){
                    maxi = i;
                }
            }
        }
        for (int x : telepulesek[maxi]){
            telepulesek[S].push_back(x);
        }
    }
    telepulesek[S].push_back(S);
   /* if (S!= N){
        int cv=0;
        for(int i=S+1;i<N;i++){
            if (tavok[i]-tavok[S]>=T){
                cv = i;
            }

        }
        for(int i=N;i>cv;i--){
            telepulesek[i].push_back(i);
            int maxe=0;
            int maxi=i;
            for (int j=i-1;j>0;j--){
                if (tavok[i]-tavok[j]>=T){
                    if(telepulesek[j].size()>maxe){
                    maxe= telepulesek[j].size();
                    maxi = j;
                    }

                }
            }
            if (maxe<N) {
                for (int y:telepulesek[maxi]){
                    telepulesek[S].push_back(y);
                }
            }
        }
        int maxi=0;
        for (int i=N; i>S;i--){
            if (tavok[i]-tavok[S]>=T){
                if (telepulesek[i].size()>telepulesek[maxi].size()){
                    maxi = i;
                }
            }
        }
        for (int x : telepulesek[maxi]){
            telepulesek[S].push_back(x);
        }
    }
        for (int y:telepulesek[S]){
            cout << y << " ";
        }
        cout << endl;*/
    int utolso=tavok[S]+T;
    for(int i=S+1;i<N+1;i++){
        if(tavok[i]>utolso){
            telepulesek[S].push_back(i);
            utolso = tavok[i]+T;
        }
    }
    cout << telepulesek[S].size() << endl;
    sort(telepulesek[S].begin(),telepulesek[S].end());
    for(int x: telepulesek[S]){
        cout << x << " ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Accepted0/03ms1816 KiB
2Runtime error0/0180ms64848 KiB
3Accepted2/23ms2236 KiB
4Accepted2/23ms2452 KiB
5Wrong answer0/23ms2664 KiB
6Accepted2/23ms2908 KiB
7Accepted2/23ms3120 KiB
8Accepted2/23ms3324 KiB
9Wrong answer0/27ms4476 KiB
10Wrong answer0/213ms6940 KiB
11Accepted2/256ms26788 KiB
12Wrong answer0/257ms26732 KiB
13Wrong answer0/229ms13864 KiB
14Runtime error0/2153ms62924 KiB
15Wrong answer0/324ms11484 KiB
16Runtime error0/3148ms62584 KiB
17Runtime error0/3153ms62556 KiB
18Runtime error0/3150ms62328 KiB
19Runtime error0/3171ms62088 KiB
20Runtime error0/3165ms61860 KiB
21Runtime error0/4165ms61840 KiB
22Time limit exceeded0/4370ms17700 KiB