-
Notifications
You must be signed in to change notification settings - Fork 0
/
192B.cpp
93 lines (85 loc) · 1.73 KB
/
192B.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <stack>
#include <cassert>
#include <fstream>
#include <cstring>
#include <numeric>
#include <ctype.h>
#include <stdio.h>
#define MOD 1000000007
#define exit return 0
#define inf 1000000000000000000LL
#define exit return 0
#define PS system("pause")
#define S 100007
#define mx(a,b) a>b?a:b
#define R0(i,n) for (i = 0; i < n; i++)
#define R1(i,n) for (i = 1; i <= n; i++)
#define MS(a,x) memset(x, a, sizeof(x));
#define left (v<<1)
#define right (left|1)
#define mid ((tl+tr)>>1)
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
using namespace std;
using ll = long long;
using ul = unsigned long long;
using PII = pair<int, int>;
const int NN = 2222;
const int NZ = 111000;
const int MM = 151;
const int mask = 1 << 4;
const int need = (1 << 30) - 1;
int n, k, m, s, x, a, b, c, q;
int l, pp;
int in[NN], comp[NN], ins[NN], low[NN];
pair<int, int>tin[NN], timer;
int main(){
scanf("%d", &n);
for (int i = 1; i <= n; i++){
scanf("%d", &a);
tin[i] = { a, i };
in[i] = 1;
}
sort(tin + 1, tin + n + 1);
int t = tin[n].first;
for (int i = 1; i <= 1000000; i++){
int y = tin[i].first;
in[tin[i].second] = 0;
for (int j = 1; j <= n - 1; j++){
if (in[j]){
int flag = 0;
if (in[j + 1] && j + 1 <= n){
in[j + 1] = 1;
flag = 1;
}
if (in[j + 2] && j + 2 <= n){
in[j + 2] = 1;
flag = 1;
}
if (!flag){
cout << y << endl;
exit;
}
}
}
if (in[n] == 0 || in[1] == 0){
cout << y << endl;
exit;
}
in[tin[i].second] = 0;
}
exit;
}