You are viewing a single comment's thread. Return to all comments →
my code fail 2 test erorr time limit why :(((
#include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { vector<int> arr; int q; cin >> q; while (q--) { int op; cin >> op; if(op == 1){ int k; cin >> k; arr.push_back(k); push_heap(arr.begin(), arr.end(), greater<int>()); } else if (op == 2) { int k; cin >> k; for (int i = 0; i < arr.size(); i++) { if(arr[i] == k) { swap(arr[arr.size()-1], arr[i]); arr.pop_back(); make_heap(arr.begin(), arr.end(), greater<int>()); break; } } } else cout << arr[0] << endl; } return 0; }```
Seems like cookies are disabled on this browser, please enable them to open this website
QHEAP1
You are viewing a single comment's thread. Return to all comments →
my code fail 2 test erorr time limit why :(((