46322023-03-30 13:21:59gyjazminSípálya (55 pont)cpp11Wrong answer 10/55500ms6072 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    iostream::sync_with_stdio(0);
    cin.tie(0);
    //beolvasas
    int n;
    int k;
    cin >> n >> k;
    vector<int> hegycsucsok(n);
    for (int i=0;i<n;i++){
        cin >> hegycsucsok[i];
    }
    int mine= INT_MAX;
    vector<int> petakok(n);
    // remelhetoleg mindenre jo modszer(csak bitanglassu)
    for(int i=0;i<n-k;i++){
            //feltolteni a vektort es megszamolni az osszeget
            vector<int> cvektor;
            for(int j=i;j<i+k;j++){
                cvektor.push_back(hegycsucsok[j]);
            }
            //masodik megoldas
            int pontok=0;
            int cv=0;
            int eddigvizsgaltakszama=1;
              //legutolsoval felpotolni mindegyiket
            cv = cvektor[k-1]+1;
            for(int l=k-2;l>=0;l--){
                    if(cvektor[l]<cv){
                        pontok += cv-cvektor[l];
                        //cvektor[l]=cv;
                        cv++;
                    }
                    else if(cvektor[l]>cv){
                        int mennyivelnagyobb = cvektor[l]-cv;
                        pontok += eddigvizsgaltakszama*mennyivelnagyobb;
                        cv = cvektor[l]+1;
                    }
                    eddigvizsgaltakszama++;
            }
            //petakokat beallitani
            petakok[i]=pontok;
            if(petakok[i]<mine){
                mine=petakok[i];
            }
    }
    //kiiras
    cout << mine << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base10/55
1Accepted0/03ms1828 KiB
2Accepted0/03ms2052 KiB
3Accepted2/23ms2156 KiB
4Accepted2/23ms2328 KiB
5Accepted2/23ms2460 KiB
6Accepted2/24ms2672 KiB
7Wrong answer0/34ms2760 KiB
8Wrong answer0/125ms3088 KiB
9Accepted1/128ms3368 KiB
10Accepted1/134ms3260 KiB
11Wrong answer0/148ms3264 KiB
12Wrong answer0/146ms3280 KiB
13Wrong answer0/1104ms3308 KiB
14Wrong answer0/2115ms3308 KiB
15Wrong answer0/248ms3552 KiB
16Time limit exceeded0/2500ms4256 KiB
17Time limit exceeded0/2476ms5476 KiB
18Time limit exceeded0/2451ms5556 KiB
19Time limit exceeded0/3463ms6072 KiB
20Time limit exceeded0/2463ms4916 KiB
21Time limit exceeded0/2432ms4680 KiB
22Time limit exceeded0/2451ms4992 KiB
23Time limit exceeded0/2435ms4988 KiB
24Time limit exceeded0/2470ms5112 KiB
25Time limit exceeded0/2483ms5276 KiB
26Time limit exceeded0/2451ms5324 KiB
27Time limit exceeded0/2472ms5364 KiB
28Time limit exceeded0/3479ms5224 KiB
29Time limit exceeded0/3476ms5468 KiB
30Time limit exceeded0/3476ms5612 KiB