rengetsu

HackerRank_AppleAndOrange

Jul 5th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. //Apple and Orange
  2. #include <cmath>
  3. #include <cstdio>
  4. #include <vector>
  5. #include <iostream>
  6. #include <algorithm>
  7. using namespace std;
  8. int main()
  9. {
  10.     int startpoint, endpoint, applelock, orangelock, m, n, apples, apcnt = 0, oranges, orcnt = 0;
  11.     cin >> startpoint >> endpoint >> applelock >> orangelock >> m >> n;
  12.     for(int i = 0; i<m; i++)
  13.     {
  14.         cin >> apples; //apples felt
  15.         if(applelock+apples >= startpoint && applelock+apples <= endpoint)
  16.         {
  17.             apcnt++;
  18.         }
  19.     }
  20.     for(int i = 0; i<n; i++)
  21.     {
  22.         cin >> oranges; //oranges felt
  23.         if(orangelock+oranges >= startpoint && orangelock+oranges <= endpoint)
  24.         {
  25.             orcnt++;
  26.         }
  27.     }
  28.     cout << apcnt << endl << orcnt << endl;
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment