Advertisement
Guest User

Counting sort 2

a guest
Dec 11th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.   int min_cost[3] = {}, cnt_cost[3] = {};
  6.   int n, mark, cost;
  7.   string name, street;
  8.  
  9.   cin >> n;
  10.   for(int i=0; i<n; ++i)
  11.   {
  12.     cin >> name >> street >> mark >> cost;
  13.     int x = (mark - 92) / 3;
  14.     if ( cost < min_cost[x] || min_cost[x] == 0 )
  15.     {
  16.       min_cost[x] = cost;
  17.       cnt_cost[x] = 1;
  18.     }
  19.     else if ( cost == min_cost[x] )
  20.       cnt_cost[x]++;
  21.   }
  22.   for(int i: cnt_cost) cout << i << " ";
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement