zoukankan      html  css  js  c++  java
  • 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     }
  • 相关阅读:
    正则表达式(验证账号密码邮箱身份证)
    JS Fetch
    事件流动
    JS DOM和BOM
    CSS的定位
    For each...in / For...in / For...of 的解释和例子
    CSS的gridlayout
    CSS position属性
    CSS的颜色
    twelfth week
  • 原文地址:https://www.cnblogs.com/cmyg/p/11108010.html
Copyright © 2011-2022 走看看