codeforces 719A Vitya in the Countryside(序列判断趋势)

时间:2024-05-14 12:34:14

题目链接:http://codeforces.com/problemset/problem/719/A

题目大意:

  题目给出了一个序列趋势 0 、1 、2 、3 ---14 、15 、14 ----3 、 2 、1 、0、1---

  输入 整数 n ,第二行输入 n(1<=n<=92) 个数,判断个数 是大于最后一个数还是小于最后一个,大于输出 UP,小于输出 DOWN,如果没法判断 输出 -1.

解题思路:

  找转折点即可。

  特判 n==1.

  剩下的代码解释。

AC Code:

 #include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int day,day1;
if(n==)
{
scanf("%d",&day);
if(day==)printf("UP\n");
else if(day==)printf("DOWN\n");
else printf("-1\n");
}
else
{
for(int i=; i<n-; i++)
scanf("%d",&day);
scanf("%d",&day1);
if(day<day1 && day1!= || day1==)printf("UP\n");
else printf("DOWN\n");
}
}
return ;
}