Codeforces Round #373 Div. 2 review
Link Codeforces Round #373 Div. 2 (Contest 719) A. Vitya in the Countryside Problem Basically, check last 2 character to determine its direction is “UP” or “DOWN”. Special case comes when the last number is 0 or 15, in that case the direction changes and you can determine the direction without looking second last character.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#include <cstdio> #include <iostream> using namespace std; int a[100]; int main(){ #ifndef ONLINE_JUDGE freopen("a3.in", "r", stdin); #endif int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } if (n >= 2) { if (a[n-1] == 15) { printf("DOWN\n"); } else if (a[n-1] == 0) { printf("UP\n"); } else { if (a[n-1] > a[n-2]) { printf("UP\n"); } else { printf("DOWN\n"); } } } else if (n == 1) { if (a[n-1] == 15) { printf("DOWN\n"); } else if (a[n-1] == 0) { printf("UP\n"); } else { printf("-1\n"); } } return 0; } |
B. Anatoly […]
Continue reading →