44752023-03-28 12:52:26gyjazminTűzijátékcpp11Runtime error 12/50352ms64848 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);
    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 << " ";
    }
    cout<< endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Accepted0/03ms1808 KiB
2Runtime error0/0186ms64848 KiB
3Accepted2/23ms2236 KiB
4Accepted2/23ms2472 KiB
5Wrong answer0/22ms2544 KiB
6Accepted2/22ms2668 KiB
7Accepted2/22ms2884 KiB
8Accepted2/23ms3144 KiB
9Wrong answer0/27ms4304 KiB
10Wrong answer0/213ms6600 KiB
11Accepted2/256ms26308 KiB
12Wrong answer0/259ms26224 KiB
13Wrong answer0/229ms13180 KiB
14Runtime error0/2151ms63556 KiB
15Wrong answer0/325ms10852 KiB
16Runtime error0/3150ms63108 KiB
17Runtime error0/3150ms62864 KiB
18Runtime error0/3151ms62632 KiB
19Runtime error0/3165ms62632 KiB
20Runtime error0/3168ms62604 KiB
21Runtime error0/4171ms62368 KiB
22Time limit exceeded0/4352ms16764 KiB