暴力模拟.
1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 5 using namespace std; 6 7 long long n,ans,tot; 8 bool vis; 9 struct kkk { 10 long long ti,v; 11 }e[100001]; 12 queue<kkk> q,q1; 13 14 int main() { 15 scanf("%lld",&n); 16 for(int i = 1;i <= n; i++) { 17 long long x,y,z; 18 scanf("%lld%lld%lld",&x,&y,&z); 19 if(x == 0) { 20 ans += y; 21 e[++tot].ti = z + 45;e[tot].v = y; 22 q.push(e[tot]); 23 } 24 if(x == 1) { 25 vis = 0; 26 while(!q.empty()) { 27 kkk o = q.front(); 28 if(o.ti < z) 29 q.pop(); 30 else 31 break; 32 } 33 while(!q.empty()) { 34 kkk o = q.front(); 35 if(o.v < y) { 36 q1.push(o); 37 q.pop(); 38 continue; 39 } 40 vis = 1; 41 q.pop(); 42 break; 43 } 44 if(!vis) ans += y; 45 while(!q.empty()) { 46 q1.push(q.front()); 47 q.pop(); 48 } 49 while(!q1.empty()) { 50 q.push(q1.front()); 51 q1.pop(); 52 } 53 } 54 } 55 printf("%lld",ans); 56 return 0; 57 }
//CSP-J 2019 T2
原文:https://www.cnblogs.com/lipeiyi520/p/11924938.html