作者:
imnoob
,
2022-01-16 21:32:05
,
所有人可见
,
阅读 24
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;
priority_queue<int, vector<int>, greater<int>> d;
priority_queue<int, vector<int>, greater<int>> t;
int main()
{
int N;
cin >> N;
while(N --){
char a;int b;
cin >> a >> b;
if(a == 'T')
t.push(b);
else d.push(b);
}
d.push(1000);
double ct = 0.0, cd = 0.0;
int rate = 1;
while(!d.empty() || !t.empty()){
bool istime = false;
if(d.empty())
istime = true;
else if(!d.empty() && !t.empty())
if(t.top() < ct + (d.top() - cd) * rate)
istime = true;
if(istime){
cd += (t.top() - ct) / (double)(rate);
ct = t.top();
t.pop();
}else{
ct += (d.top() - cd) * rate;
cd = d.top();
d.pop();
}
rate ++;
}
cout << (int)round(ct);
}