Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <stdio.h>
- using namespace std;
- void distribution(vector<int> &A, vector<int> &B, vector<int> working, int a, int b)
- {
- for(int i = 0; i < a; i++)
- A.push_back(working[i]);
- for(int i = a; i < a + b; i++)
- B.push_back(working[i]);
- }
- void equal(int a)
- {
- for(int i = 0; i < a; i++)
- printf("1 ");
- for(int i = 0; i < a; i++)
- printf("2 ");
- }
- int main()
- {
- int n, a, b;
- scanf("%d%d%d", &n, &a, &b);
- vector<int> line, working;
- for(int i = 0; i < n; i++)
- {
- int current;
- scanf("%d", ¤t);
- line.push_back(current);
- }
- working = line;
- sort(working.begin(), working.end());
- vector<int> A, B;
- if (b > a)
- distribution(B, A, working, b, a);
- if (a > b)
- distribution(A, B, working, a, b);
- if (a == b)
- {
- equal(a);
- return 0;
- }
- for(int i = 0; i < n; i++)
- {
- vector<int>::iterator it = A.begin();
- it = find(A.begin(), A.end(), line[i]);
- if (it != A.end())
- {
- printf("1 ");
- A.erase(it);
- }
- else
- {
- it = find(B.begin(), B.end(), line[i]);
- printf("2 ");
- B.erase(it);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement