zoukankan      html  css  js  c++  java
  • 洛谷P1159 排行榜 模拟

    洛谷P1159 排行榜

    模拟

    DOWN的人 正序 排到前面
    UP的人 正序 排在后面
    然而要注意 SAME 是不变的
    所以说SAME 的位置是固定的,这个要特殊做

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <string>
     4 #include <iostream>
     5 using namespace std ; 
     6 
     7 int n,topu,topd ; 
     8 string up[101],down[101],all[101] ; 
     9 string s,type ; 
    10 bool f[101] ; 
    11 
    12 int main() 
    13 {
    14     cin>>n ; 
    15     topu = 0 ; topd = 0 ; 
    16     for(int i=1;i<=n;i++)
    17     {
    18         cin>>all[ i ]>>type ;
    19         if(type[ 0 ]=='D') down[++topd] = all[ i ] ; 
    20         if(type[ 0 ]=='S') f[ i ] = 1 ; 
    21         if(type[ 0 ]=='U') up[++topu] = all[ i ] ;   
    22     }
    23     int zd = 1 , zu = 1 ; 
    24     for(int i=1;i<=n;i++) 
    25     {
    26         if( f[ i ] ) 
    27         {
    28             cout<<all[ i ]<<endl ; 
    29             continue ; 
    30         }
    31         if( zd<=topd ) 
    32             cout<<down[zd]<<endl ,zd++ ; 
    33         else
    34             cout<<up[zu]<<endl ,zu++ ;  
    35     }
    36     return 0 ; 
    37 }
  • 相关阅读:
    Redis Java客户端之Lettuce
    Redis Java客户端之Redisson
    Redis Java客户端的比较
    Redis布隆过滤器
    过期删除策略和内存淘汰策略
    集群模式详解
    哨兵模式详解
    Redis Java客户端之Jedis
    主从复制
    AOF持久化
  • 原文地址:https://www.cnblogs.com/third2333/p/7094061.html
Copyright © 2011-2022 走看看