int main() { Tree<int> tree; Treap<int> treap; int n = 0; cin >> n; int value = 0; int priority = 0; for(int i = 0; i < n; i++) { cin >> value >> priority; tree.Add(value); treap.Add(value, priority); } cout << tree.Height() - treap.Height(); return 0; }
int main() { size_t elementsNumber = 0; cin >> elementsNumber; if ( elementsNumber == 0 ) { return 1; } BinaryTree binaryTree; Treap treap; for ( size_t i = 0; i < elementsNumber; ++i ) { int k = 0; int p = 0; cin >> k >> p; binaryTree.Add( k ); treap.Add( k, p ); } const int result = (int)treap.GetWidestLayer() - (int)binaryTree.GetWidestLayer(); cout << result; return 0; }