Advertisement
coffeebeforecode

Distribute T-Shirts in a Marathon

Jun 20th, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. #include <stack>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9.     int n;
  10.     stack<int> tshirts;
  11.     queue<string> participants;
  12.     cin >> n;
  13.     int o;
  14.     string ns;
  15.     int k, t;
  16.     while(n--){
  17.         cin >> o;
  18.         switch(o){
  19.             case 1:
  20.                 cin >> k;
  21.                 for(int i = 0; i < k; i++){
  22.                     cin >> ns;
  23.                     participants.push(ns);
  24.                 }
  25.                 break;
  26.             case 2:
  27.                 cin >> k;
  28.                 for(int i = 0; i < k; i++){
  29.                     cin >> t;
  30.                     tshirts.push(t);
  31.                 }
  32.                 break;
  33.             case 3:
  34.                 cin >> k;
  35.                 for(int i = 0; i < k; i++){
  36.                     cout << participants.front() << " " << tshirts.top() << endl;
  37.                     participants.pop();
  38.                     tshirts.pop();
  39.                 }
  40.                 break;
  41.         }
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement