Educational Codeforces Round 27 D. Driving Test
Posted cmyg
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 27 D. Driving Test相关的知识,希望对你有一定的参考价值。
单调栈
题意看了半天。。。
1 #include <cstdio> 2 #include <cstdlib> 3 #include <cmath> 4 #include <cstring> 5 #include <string> 6 #include <algorithm> 7 #include <iostream> 8 using namespace std; 9 #define ll long long 10 11 const int maxn=2e5+10; 12 const int inf=1e9; 13 14 int sum1,tot1; 15 int f[maxn],g; 16 17 int main() 18 19 int n,a,b,i,j,v; 20 scanf("%d",&n); 21 for (i=1;i<=n;i++) 22 23 scanf("%d",&a); 24 if (a==1 || a==3) 25 scanf("%d",&b); 26 27 if (a==4) 28 tot1=0; 29 else if (a==6) 30 tot1++; 31 else if (a==2) 32 sum1+=tot1,tot1=0; 33 34 if (a==5) 35 g=0; 36 else if (a==1) 37 38 v=b; 39 while (g>0 && f[g]<v) 40 g--,sum1++; 41 42 else if (a==3) 43 44 if (b<v) 45 sum1++; 46 else 47 f[++g]=b; 48 49 50 printf("%d",sum1); 51 return 0; 52
以上是关于Educational Codeforces Round 27 D. Driving Test的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 7 A
Educational Codeforces Round 7
Educational Codeforces Round 90
Educational Codeforces Round 33