链接:[http://codeforces.com/group/1EzrFFyOc0/contest/719/problem/A]
题意:
给你一个数列(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1),然后重复循环这个数列,输入一个n,再输入有n个元素的某段,问你接下来是UP还是DOWN,若无法判断输出-1。
思路:
枚举各种情况,注意n1,a[n]15是DOWN。
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,i,a[100];
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
if(n==1&&a[n]==0){
cout<<"UP\n";
}
else if(n==1&&a[n]==15){
cout<<"DOWN\n";
}
else if(n==1&&a[n]!=0)
{
cout<<-1<<endl;
}
else if(a[n-1]<a[n]&&a[n]!=15)
{
cout<<"UP\n";
}
else if(a[n-1]<a[n]&&a[n]==15){
cout<<"DOWN\n";
}
else if(a[n-1]>a[n]&&a[n]!=0){
cout<<"DOWN\n";
}
else if(a[n-1]>a[n]&&a[n]==0){
cout<<"UP\n";
}
return 0;
}