Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- using namespace std;
- int o,n,m,t,h;
- const int MaxO = 1000;
- int a[MaxO][4];
- int b[MaxO];
- int c[MaxO];
- void beolvas()
- {
- cin >> o >> n >> m >> t >> h;
- for (int i = 0; i < o; i++)
- {
- for (int j = 0; j < 4; ++j)
- cin >> a[i][j];
- }
- }
- int main()
- {
- beolvas();
- int vegso_lyuk = 999;
- int tanar = 0;
- int napok[6][10];
- for(int i = 1; i <= n ; i++ )
- {
- int he = 0;
- int k = 0;
- int sz = 0;
- int cs = 0;
- int p = 0;
- for(int sor = 0; sor < o; sor++)
- {
- if(a[sor][0] == i)
- {
- if(a[sor][2] == 1)
- {
- napok[0][he] = a[sor][3];
- he++;
- }
- if(a[sor][2] == 2)
- {
- napok[1][k] = a[sor][3];
- k++;
- }
- if(a[sor][2] == 3)
- {
- napok[2][sz] = a[sor][3];
- sz++;
- }
- if(a[sor][2] == 4)
- {
- napok[3][cs] = a[sor][3];
- cs++;
- }
- if(a[sor][2] == 5)
- {
- napok[4][p] = a[sor][3];
- p++;
- }
- }
- }
- int tomb[5] = {he,k,sz, cs, p};
- for(int z = 0; z < 5; z++)
- {
- for(int x = 0; x < tomb[z]-1; x++)
- {
- for(int y = x+1; y<tomb[z]; y++)
- {
- if (napok[z][x] > napok[z][y])
- {
- int save = napok[z][x];
- napok[z][x] = napok[z][y];
- napok[z][y] = save;
- }
- }
- }
- }
- int lyuk = 0;
- for(int z = 0; z < 5; z++)
- {
- if (tomb[z] > 1)
- {
- lyuk = lyuk + napok[z][tomb[z]-1] - napok[z][0]-tomb[z] + 1;
- }
- }
- if(vegso_lyuk > lyuk)
- {
- vegso_lyuk = lyuk;
- tanar = i;
- }
- }
- cout << tanar << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement