114902024-10-11 09:18:18madvirMekk Mester munkái (50 pont)cpp17Wrong answer 0/50697ms1640 KiB
#include <iostream>
#include <vector>
#include <iterator>

using namespace std;

vector<int> mester, fia;
vector<int> munka;

struct meg{
    int k,v,szam;
}t[100001];

void moho(int n,int &c,vector<int> m) {
    c=0;
    cout << "c=" << c << ", ";
    int x=t[0].v;
    cout << "x=" << x << ", ";
    c++;
    cout << "c=" << c << " ";
    m.push_back(t[0].szam);
    for(int i=1; i<n; i++) {
        if(x<t[i].k) {
            m.push_back(t[i].szam);
            x=t[i].v;
        }
    }
}

int main()
{
    int n,h;
    cin >> n >> h;
    for(int i=0; i<n; i++) {
        cin >> t[i].k >> t[i].v;
        t[i].szam=i+1;
    }

    ///doc alapjan!!

    int jo=0, m=n;

    meg x;

    ///rendezzuk befejezes szerint

    while(jo==0) {
        jo=1;
        for(int i=0; i<m-1; i++) {
            if(t[i].v>t[i+1].v) {
                x=t[i];
                t[i]=t[i+1];
                t[i+1]=x;
                jo=0;
            }
        }
        m--;
    }

    for(int i=0; i<n; i++) {
        munka.push_back(t[i].szam);
    }



    /*for(int i=0; i<n; i++) {
        cout << t[i].szam << " " << t[i]. k << " " << t[i].v << endl;
    }*/

    ///moho

    int cm=0, cf=0, y=0;

    ///eloszor a mesternek, utana a fianak
    ///most a mesternek

    vector<int>::iterator ptr;

    ptr=munka.begin();

    int w=t[0].v;
    munka.erase(ptr);
    cm++;
    mester.push_back(t[0].szam);
    while(y<n) {
        if(w<t[y].k) {
            mester.push_back(t[y].szam);
            w=t[y].v;
            cm++;
            munka.erase(ptr);
        }
        y++;
        ptr++;
    }

    ptr=munka.begin();
    w=t[0].v;
    cf++;
    fia.push_back(t[0].szam);
    while(y<n) {
        if(w<t[y].k) {
            fia.push_back(t[y].szam);
            w=t[y].v;
            cf++;
        }
        y++;
    }



    cout << cm << " " << cf;

    /*for(int i=0; i<cm; i++) {
        cout << mester[i] << " ";
    }

    for(int i=0; i<cf; i++) {
        cout << fia[i] << " ";
    }*/


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms504 KiB
2Wrong answer0/0219ms544 KiB
3Runtime error0/13ms796 KiB
4Wrong answer0/13ms668 KiB
5Wrong answer0/22ms360 KiB
6Runtime error0/23ms504 KiB
7Runtime error0/23ms616 KiB
8Runtime error0/23ms488 KiB
9Runtime error0/33ms488 KiB
10Runtime error0/14ms524 KiB
11Wrong answer0/14ms360 KiB
12Wrong answer0/24ms360 KiB
13Wrong answer0/24ms504 KiB
14Runtime error0/24ms488 KiB
15Runtime error0/24ms632 KiB
16Runtime error0/34ms360 KiB
17Time limit exceeded0/2697ms1384 KiB
18Time limit exceeded0/2695ms1512 KiB
19Time limit exceeded0/4694ms1512 KiB
20Time limit exceeded0/4695ms1512 KiB
21Time limit exceeded0/4694ms1640 KiB
22Time limit exceeded0/4697ms1512 KiB
23Time limit exceeded0/4695ms1512 KiB