#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
map<int, int>M;
int n,sum=0;
int main() {
cin >> n;
auto it = M.begin();
for (int i = 1; i <= n; i++) {
int a, b, c;
cin >> a >> b >> c;//c is time,b is price
if (a == 0) //乘地铁
M[c]=b,sum+=b;
else {
while (it != M.end()) {
if (c - it->second > 45) it++;
else break;
}
if (it == M.end()||it->second<b) sum += b;//没有票可以用,付钱
else it++;//把票用了
}
//cout << sum << " "<<endl;
}
cout << sum;
}
求助,不会用map