yordanganev

cp2019_zad9_start

Apr 3rd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. #define print(var) cout << #var << ": " << var<< endl;
  5.  
  6. using namespace std;
  7.  
  8. const int fzs = 1000001;
  9. int feetSizes[fzs];
  10.  
  11. int main() {
  12.     int tests;
  13.     cin >> tests;
  14.  
  15.     for (int test = 0; test < tests; test++) {
  16.         int shoesCount;
  17.         int feetCount;
  18.         cin >> shoesCount;
  19.         cin >> feetCount;
  20.  
  21.         print(shoesCount);
  22.         print(feetCount);
  23.        
  24.         const int lastSize = 50;
  25.         int shoes[lastSize];
  26.  
  27.         for (int i = 20; i < 50; i++) {
  28.             shoes[i] = 0;
  29.         }
  30.  
  31.         for (int i = 0; i < shoesCount; i++) {
  32.             int shoeSize;
  33.             cin >> shoeSize;
  34.             shoes[shoeSize]++;
  35.         }
  36.        
  37.         for (int i = 0; i < feetCount; i++) {
  38.             cin >> feetSizes[i];
  39.         }
  40.         sort(feetSizes, feetSizes + feetCount);
  41.  
  42.         int skiers = 0;
  43.  
  44.         for (int i = 0; i < feetCount; i++) {
  45.             if (shoes[feetSizes[i]]) {
  46.                 skiers++;
  47.                 shoes[feetSizes[i]]--;
  48.                 //cout << skiers << " : " << shoes[feetSizes[i]] << endl;
  49.                 feetSizes[i] = 0;
  50.             }
  51.         }
  52.         cout << skiers << endl;
  53.  
  54.         for (int i = 20; i < 50; i++) {
  55.             cout << i << " : " << shoes[i] << endl;
  56.         }
  57.  
  58.         for (int i = 0; i < feetCount; i++) {
  59.             cout << i << " : " << feetSizes[i] << endl;
  60.         }
  61.  
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment