In fact, an ordinary simulation title, but the data do not make a lot of 1e5's look at the data range and without optimization of small partners inexplicable T a. ( Including me )
Therefore, on the importance of reducing shoots! !
Ever since, the most important thing will come out. What has long expired tickets need to search it! !
#include <bits / STDC ++ H.> the using namespace STD; #define N 666666 struct Piao { int T,. price, VIS; } P [N]; namespace Work { int ANS = 0 , CAC = 0 ; int Last = . 1 ; int read () { // data bit large, and fast read little insurance char C; int X = 0 , S = . 1 ; C = getchar (); the while (C < ' 0 ' || C> ' 9'){ if(c == '-')s = -1; c = getchar(); } while(c >= '0' && c <= '9')x = x * 10 + c - '0',c = getchar(); return x * s; } void main(int n){ for(int i = 1;i <= n;i++){ intTime,. price, A; A = Read (), Read. price = (), Time = Read (); ANS + = . price; IF (A == 0 ) { P [ ++ CAC] = .price . price; P [ CAC] .T = Time; } IF (A == . 1 ) { for ( int I = Last; I <= CAC; I ++ ) { IF (Time - P [I] .T> 45 ) Last = I; // this sentence is the most important, the long time out of all cut, cut this part enough to the AC IF (the p-[i] && .vis Time -! the p-[i] .T <= 45P && [I] .price> = . Price) { ANS - = . Price; P [I] .vis = . 1 ; // have already used, no longer used BREAK ; } } } } the printf ( " % D " , ANS ); } } int main () { int n-= Work :: Read (); Work :: main (n-); return 0 ; }
(Though not test the popularity of the group, but the water of simulation title is still possible)