zoukankan      html  css  js  c++  java
  • 【ECJTU_ACM 11级队员2012年暑假训练赛(7) D Little Elephant and Rozdil】

    D - Little Elephant and Rozdil
    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

    Description

    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 n integers, 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 Input

    Input
    2
    7 4
    Output
    2
    Input
    7
    7 4 47 100 4 9 12
    Output
    Still Rozdil

    Hint

    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 equals 4, so the answer is "Still Rozdil".

     1 #include <iostream>
     2 using namespace std;
     3 
     4 typedef unsigned long long int longint;
     5 
     6 longint* iMap;
     7 
     8 int main()
     9 {
    10     int n;
    11     while (cin >> n)
    12     {
    13         iMap = new longint[n];
    14         for (int i = 0; i < n; i++)
    15         {
    16             cin >> iMap[i];
    17         }
    18 
    19         int flag = 0;
    20         for (int i = 0; i < n; i++)
    21         {
    22             if (iMap[i] < iMap[flag])
    23             {
    24                 flag = i;
    25             }
    26         }
    27 
    28         int count = 0;
    29         for (int i = 0; i < n; i++)
    30         {
    31             if (iMap[i] == iMap[flag])
    32             {
    33                 count++;
    34             }
    35         }
    36         if (count == 1)
    37         {
    38             cout << flag + 1 << endl;
    39         }
    40         else
    41         {
    42             cout << "Still Rozdil" << endl;
    43         }
    44 
    45         delete[] iMap;
    46     }
    47     return 0;
    48 }
    49 
    50 
    51 // end
    52 // ism
  • 相关阅读:
    border-radius属性失效问题的解决办法
    提示:Cannot set property 'height' of undefined
    图片大小自适应
    css实现图片大小自适应
    纯html静态页面获取参数(用javascript传递页面参数)
    01背包的两个主要函数
    HDU1171将多个不同价值不同数量的器材尽可能按等价值均分 第一份的价值尽可能的大 所以sum/2对第二份进行01背包 使其价值尽可能的大
    HDU5616 天平能否称出物体重量问题 01背包变形或者折半搜索
    树状数组模板
    《Linux就该这么学》第七课
  • 原文地址:https://www.cnblogs.com/ismdeep/p/2624398.html
Copyright © 2011-2022 走看看