59752023-10-08 09:37:34neszbalUtazásszervezés (75 pont)cpp17Accepted 75/756ms4008 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int getIndex(vector<int> v, int X) {
    auto it = find(v.begin(), v.end(), X);
    if (it != v.end()) {
        int index = it - v.begin();
        return index;
    }
    else {
        return -1;
    }
}



int main() {
    /*  2 10 4 6
        1 2 2 5 6 7
    */

    int N, K, M, C, a=0;

    cin >> N >> K >> M >> C;
    vector<int> igenyek(C);
    vector<int> kiserok(N, -1);

    for (int i = 0; i < C; i++) {
        cin >> igenyek[i];
    }

    for(int i=0; i<C; i++) {


        int idegenvezeto = getIndex(kiserok, -1);
        if (idegenvezeto != -1) {
            kiserok[idegenvezeto] = igenyek[i]+M-1;
            a++;
        } else {
            for (int j = 0; j < N; j++) {
                if(kiserok[j] < igenyek[i]) {
                    kiserok[j] = igenyek[i] + M - 1;
                    a++;
                    break;
                }
            }
        }

            
        
        
        

    }


    cout << a << endl;



    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1936 KiB
2Accepted0/06ms2264 KiB
3Accepted3/32ms2124 KiB
4Accepted4/42ms2256 KiB
5Accepted4/43ms2472 KiB
6Accepted4/42ms2580 KiB
7Accepted4/42ms2604 KiB
8Accepted4/42ms2680 KiB
9Accepted5/53ms2780 KiB
10Accepted5/53ms2996 KiB
11Accepted6/64ms3220 KiB
12Accepted6/64ms3320 KiB
13Accepted6/64ms3320 KiB
14Accepted6/66ms3580 KiB
15Accepted6/66ms3792 KiB
16Accepted6/66ms3752 KiB
17Accepted6/66ms4008 KiB