本蒟蒻突发奇想用map写,结果TLE了...
#include<bits/stdc++.h>
#define int long long
using namespace std;
map<int, int> a;
int n;
signed main(){
cin >> n;
int ans = 0;
for(int i = 1; i <= n; i++){
int o, p, t;
cin >> o >> p >> t;
if(o == 0){
ans += p;
a[t] = p;
}
else{
int f = 0;
for(int j = t - 45; j <= t; j++){
if(a[j] >= p){
a[j] = -1;
f = 1;
break;
}
}
if(!f){
ans += p;
}
}
}
cout << ans;
return 0;
}
求大佬解答