#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll t;
cin >> t;
while (t--) {
priority_queue<ll> lmax;
priority_queue<ll, std::vector<ll>, greater<ll> > rmin;
ll a, b, c, n;
cin >> a >> b >> c >> n;
ll sum = 1;
lmax.push(1);
for (int i = 2; i <= n; i++) {
if (abs(lmax.size() - rmin.size()) >= 2) {
if (lmax.size() > rmin.size()) {
rmin.push(lmax.top());
lmax.pop();
}
else {
lmax.push(rmin.top());
rmin.pop();
}
}
ll median = 0;
if (lmax.size() > rmin.size())median = lmax.top();
else if (lmax.empty() || lmax.size() < rmin.size())median = rmin.top();
else median = lmax.top();
ll func = fmod((a * median + b * i + c), 1000000007);
sum += func;
if (func <= lmax.top())lmax.push(func);
else rmin.push(func);
}
cout << sum << endl;
}
return 0;
}`Preformatted text`
I have used two priority queues lmax(max priority queue) to store all the elements lower than median and the rmin(min priority queue) to elements greater than median.Please help to find what 's wrong with the above code?I’m getting WA