zoukankan      html  css  js  c++  java
  • <codeforces>A. Little Elephant and Rozdil

    A. Little Elephant and Rozdil
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    The Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. "Rozdil").

    However, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn't like to spend much time on travelling, so for his journey he will choose a town that needs minimum time to travel to. If there are multiple such cities, then the Little Elephant won't go anywhere.

    For each town except for Rozdil you know the time needed to travel to this town. Find the town the Little Elephant will go to or print "Still Rozdil", if he stays in Rozdil.

    Input

    The first line contains a single integer n (1 ≤ n ≤ 105) — the number of cities. The next line contains nintegers, separated by single spaces: the i-th integer represents the time needed to go from town Rozdil to the i-th town. The time values are positive integers, not exceeding 109.

    You can consider the cities numbered from 1 to n, inclusive. Rozdil is not among the numbered cities.

    Output

    Print the answer on a single line — the number of the town the Little Elephant will go to. If there are multiple cities with minimum travel time, print "Still Rozdil" (without the quotes).

    Sample test(s)
    input
    2
    7 4
    
    output
    2
    
    input
    7
    7 4 47 100 4 9 12
    
    output
    Still Rozdil
    
    Note

    In the first sample there are only two cities where the Little Elephant can go. The travel time for the first town equals 7, to the second one — 4. The town which is closest to Rodzil (the only one) is the second one, so the answer is 2.

    In the second sample the closest cities are cities two and five, the travelling time to both of them equals4, so the answer is "Still Rozdil".

    AC code:

    #include <iostream>
    using namespace std;
    int main()
    {
        int n,min,order,c,i;
        bool flag;
        while(cin>>n>>c)
        {
            min=c;
            order=1;
            flag=true;//这个标志是关键
            for(i=2;i<=n;i++)
            {
                cin>>c;
                if(c<min)
                {
                    min=c;
                    order=i;
                    if(!flag) flag=true;
                }
                else if(c==min) flag=false;
            }
            if(flag) cout<<order<<endl;
            else cout<<"Still Rozdil"<<endl;
        }
        return 0;
    }
    



  • 相关阅读:
    如何反编译Python写的exe到py
    Liunx常用查找,授权,启动命令
    判断ArrayList集合内是否包含某个元素
    SpringApplicationBuilder作用,以及设置跨域请求过滤器,字符编码,打war包用tomcat运行
    JSON数据解析:Gson(谷歌)和fastjson(阿里巴巴)的异同
    转载:docker安装mycat
    转载:sqlserver 开启快照
    windows 开启操作系统审核策略功能,并设置日志保留不少于180天
    mysql数据库表同步命令
    macos 忘记开机密码,重设密码
  • 原文地址:https://www.cnblogs.com/cszlg/p/2910599.html
Copyright © 2011-2022 走看看