75762024-01-09 20:06:35xxxProgramtermék verseny (70 pont)cpp17Accepted 70/7041ms4744 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n+1), b(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }



    int helyezes = 1;

    for(int i = 1; i <= n; i++) {
        if (a[i] > a[k]) {
            helyezes++;
        }

        b[i] = helyezes;
    }


    int ans1, ans2, ans3;
    ans1 = ans2 = ans3 = 0;
    int arany = n/12, ezust = n/4, bronz = n/2;

    for(int i = k; i < n; i++) {
        if (b[i] <= arany && b[i+1] > arany && !ans1) {
            ans1 = i;
        }
        if (b[i] <= ezust && b[i+1] > ezust && !ans2) {
            ans2 = i;
        }
        if (b[i] <= bronz && b[i+1] > bronz && !ans3) {
            ans3 = i;
        }
    }

    if(b[n] <= bronz && b[n] > ezust) {
        ans3 = n;
    }
    else if (b[n] <= ezust && b[n] > arany) {
        ans2 = n;
    }
    else if (b[n] <= arany) {
        ans1 = n;
    }

    cout << ans1 << '\n' << ans2 << '\n' << ans3 << '\n';


	return 0;
}
SubtaskSumTestVerdictTimeMemory
base70/70
1Accepted0/03ms1808 KiB
2Accepted0/03ms2060 KiB
3Accepted0/041ms3500 KiB
4Accepted3/33ms2216 KiB
5Accepted3/33ms2332 KiB
6Accepted3/32ms2404 KiB
7Accepted3/33ms2648 KiB
8Accepted3/32ms2612 KiB
9Accepted3/32ms2620 KiB
10Accepted3/33ms2620 KiB
11Accepted3/33ms2736 KiB
12Accepted3/33ms2640 KiB
13Accepted3/33ms2656 KiB
14Accepted4/44ms2792 KiB
15Accepted4/420ms3544 KiB
16Accepted4/425ms3644 KiB
17Accepted4/428ms3672 KiB
18Accepted4/46ms2912 KiB
19Accepted4/49ms3292 KiB
20Accepted4/413ms3416 KiB
21Accepted4/441ms4540 KiB
22Accepted4/441ms4744 KiB
23Accepted4/435ms4704 KiB