Advertisement
erfanul007

Untitled

Jan 12th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int> pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define pb push_back
  14. #define pob pop_back
  15. #define mp make_pair
  16. #define ff first
  17. #define ss second
  18. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  19. #define loop(i,y) for(int i=0; i<int(y); i++)
  20. #define rloop(i,y) for(int i=int(y); i>0; i--)
  21. #define rloop1(i,y) for(int i=int(y)-1; i>=0; i--)
  22. #define read() freopen("input.txt", "r", stdin)
  23. #define write() freopen("output.txt", "w", stdout)
  24. #define cspf(i) printf("Case %d: ", i)
  25. /// Constants
  26. #define eps 1e-9
  27. #define PI acos(-1.0) // 3.1415926535897932
  28.  
  29. int main()
  30. {
  31. int n,k,x,cnt;
  32. cin>>n>>k;
  33. if(n<k){
  34. cout<<"NO"<<endl;
  35. return 0;
  36. }
  37. vpii vt(n);
  38. loop(i,n){
  39. cin>>vt[i].ff;
  40. vt[i].ss=i;
  41. }
  42. sort(vt.begin(),vt.end());
  43. vi cl(n);
  44. x=0;
  45. cnt=0;
  46. loop(i,n){
  47. cnt++;
  48. if(cnt>k){
  49. cout<<"NO"<<endl;
  50. return 0;
  51. }
  52. cl[vt[i].ss]=x;
  53. x=(x+1)%k;
  54. if(i<n-1){
  55. if(vt[i].ff!=vt[i+1].ff)
  56. cnt=0;
  57. }
  58. }
  59. cout<<"YES"<<endl;
  60. loop(i,n){
  61. cout<<cl[i]+1;
  62. if(i<n-1)
  63. cout<<" ";
  64. }
  65. cout<<endl;
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement