Daffodil International University
Problem Link
//Please follow from main function
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, sum=0;
cin>>n;
vector<int>num(n+5), cnt(n+5), cnt2(n+5);
for(int i=0; i<n; i++){
cin>>num[i];
}
for(int i=0; i<n; i++){
cnt[n-num[i]]++;
if(cnt[n-num[i]]%(n-num[i])==0)sum+=(n-num[i]);
}
if(sum==n){
cout<<"Possible"<<endl;
map<int, int>mp;
int type=1;
for(int i=0; i<n; i++){
if(cnt2[n-num[i]]%(n-num[i])==0){
mp[n-num[i]]=type++;
}
cnt2[n-num[i]]++;
cout<<mp[n-num[i]]<<' ';
}
}
else cout<<"Impossible"<<endl;
return 0;
}
0 Comments