Advertisement
Derga

Untitled

Jan 12th, 2024 (edited)
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <unordered_map>
  3. #include <unordered_set>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     unordered_map<int, unordered_set<int>> tc_ac;//key - turtles count, value - turtles counts after i-th turtle
  9.     size_t operations_count;
  10.     cin >> operations_count;
  11.     for (size_t i = 0; i < operations_count; ++i) {
  12.         int before, after; //turtles count before i-th turtle and turtles count afetr i-th turtle
  13.         cin >> before >> after;
  14.         //if (before < 0 || after < 0) continue;
  15.  
  16.         tc_ac[before + 1 + after].insert(after);
  17.     }
  18.  
  19.     int result = tc_ac.begin()->second.size();
  20.     for (const auto& [_, after] : tc_ac) {
  21.         if (after.size() > result) result = after.size();
  22.     }
  23.     cout << result;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement