-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomp.cpp
More file actions
54 lines (42 loc) · 944 Bytes
/
comp.cpp
File metadata and controls
54 lines (42 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
using namespace std;
bool comp(const pair<int,int> &a, const pair<int,int> &b)
{
if(a.first == b.first) return a.second>b.second;
else return a.first<b.first;
}
int main()
{
int n;
cin>>n;
int a,b;
cin>>a>>b;
vector<pair<int,int> > A;
int v;
for(int i = 0;i<n;i++)
{
cin>>v;
A.push_back(make_pair(v,i));
//A[i][1] = i;
}
if(a==b) {
for(int i = 0;i<a;i++){cout<<"1 ";}
while(b>0) {cout<<"2 "; b=b-1;}
}
else if(a<b)
{
sort(A.begin(),A.end(),comp);
int S[n];
for(int i = 0;i<n;i++){ if(i<a) {S[A[n-1-i].second] = 1;}
else S[A[n-i-1].second] = 2;}
for(int i = 0;i<n;i++) cout<<S[i]<<" ";
}
else
{
sort(A.begin(),A.end());
int S[n];
for(int i = 0;i<n;i++){ if(i<a) {S[A[i].second] = 1;}
else S[A[i].second] = 2;}
for(int i = 0;i<n;i++) cout<<S[i]<<" ";
}
}