fork download
  1. #include<bits/stdc++.h>
  2. typedef long long int ll;
  3. #define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
  4. using namespace std;
  5. bool mycompare(const pair<ll,ll>p1,const pair<ll,ll>p2)
  6. { if(p1.first==p2.first)
  7. {return p1.second<p2.second;}
  8. else
  9. return p1.first<p2.first;
  10. }
  11. int main()
  12. { fast;
  13. int t,c=0; cin>>t;
  14. while(t--)
  15. { c++;
  16. ll n,x; cin>>n>>x;
  17. vector<pair<ll,ll>>v;
  18. for(ll i=1;i<=n;i++)
  19. {ll temp; cin>>temp;
  20. if(temp<=x)
  21. v.push_back(make_pair(0,i));
  22. else
  23. v.push_back(make_pair((ceil((double)temp/(double)x)),i));}
  24. vector<ll>ans;
  25. for(auto it:v)
  26. {cout<<it.first<<":"<<it.second<<endl;}
  27. sort(v.begin(),v.end(),mycompare);
  28. for(auto i:v)
  29. {ans.push_back(i.second);}
  30.  
  31. cout<<"Case #"<<c<<": ";
  32. for(auto i:ans)
  33. {cout<<i<<" ";}
  34. cout<<endl;
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 4444KB
stdin
1
5 2
3 5 1 2 4
stdout
2:1
3:2
0:3
0:4
2:5
Case #1: 3 4 1 5 2