20822022-12-16 19:58:34eokorRendőrségi Üldözés 4cpp11Wrong answer 10/1002.599s4620 KiB
#include <iostream>
//#include <fstream>

using namespace std;

int n,hossz,t,osszegv=0,mini=1000;
long int lampa[10000];

void backtrack(int i, int alltam, int seg, int mehet){
    if(i<=n)
    {
        if((lampa[i]+alltam)/t%2==0)//zold
             {
                 backtrack(i+1,alltam,seg,mehet);
             }

        else{
            if(mehet>0)//athajthatok
        {
            backtrack(i+1,alltam,seg,mehet-1);
        }
            seg=t-lampa[i]%t;
            backtrack(i+1,alltam+seg,seg,mehet);
        }

    }
    else
        {
            if(alltam<mini)
            {
                mini=alltam;
            }
        }
}

int main()
{
//    ifstream cin("be1.txt");
    int seg=0,alltam=0,mehet;
    cin>>n>>mehet>>t>>hossz;
    osszegv=hossz;
    lampa[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>lampa[i];
    }
    backtrack(1,0,0,mehet);
    cout<<osszegv+mini;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1756 KiB
2Accepted2ms1920 KiB
subtask210/10
3Accepted2ms2124 KiB
4Accepted2ms2636 KiB
5Accepted2ms2580 KiB
6Accepted2ms2556 KiB
7Accepted2ms2684 KiB
subtask30/15
8Wrong answer2ms2788 KiB
9Accepted2ms2764 KiB
10Wrong answer2ms3036 KiB
11Wrong answer2ms3176 KiB
subtask40/15
12Accepted2ms3176 KiB
13Wrong answer2ms3416 KiB
14Accepted3ms3556 KiB
15Wrong answer2ms3912 KiB
subtask50/25
16Time limit exceeded2.599s4100 KiB
17Time limit exceeded2.581s3280 KiB
18Time limit exceeded2.542s4124 KiB
19Time limit exceeded2.569s4168 KiB
20Time limit exceeded2.572s4032 KiB
subtask60/15
21Time limit exceeded2.545s3208 KiB
22Time limit exceeded2.565s4152 KiB
23Time limit exceeded2.565s3268 KiB
24Time limit exceeded2.565s3272 KiB
25Time limit exceeded2.585s4244 KiB
subtask70/20
26Runtime error7ms4320 KiB
27Runtime error7ms4320 KiB
28Runtime error7ms4500 KiB
29Runtime error7ms4488 KiB
30Runtime error7ms4620 KiB