Advertisement
abs25

Tena

Jan 30th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <utility>
  5. #include <vector>
  6. #include <algorithm>
  7.  
  8. int main()
  9. {
  10.     int x, y, num;
  11.     std::string input;
  12.     std::string command;
  13.     getline(std::cin, input, '#');
  14.     std::cin >> num;
  15.  
  16.     std::stringstream ss(input);
  17.     std::vector<std::pair<int, int>> data;
  18.  
  19.     while (!ss.eof()) {
  20.         ss >> command >> x >> y;
  21.         if (ss.fail()) {
  22.             ss.clear();
  23.             break;
  24.         }
  25.         for (int i = 1; i < num + 1; i++)
  26.         {
  27.             data.emplace_back(i*y, x);
  28.         }
  29.     }
  30.  
  31.     std::sort(data.begin(), data.end());
  32.  
  33.     for (int i = 0; i < num; i++)
  34.     {
  35.         //std::cout << data[i].first << ", " << data[i].second << std::endl;
  36.         std::cout << data[i].second << std::endl;
  37.     }
  38.     system("PAUSE");
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement