-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1199A.cpp
More file actions
151 lines (147 loc) · 3.62 KB
/
1199A.cpp
File metadata and controls
151 lines (147 loc) · 3.62 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Author : Chinmay Jha
// @chinmayajha on Codeforces, Codechef, USACO, AtCoder and CSES.fi
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define ll long long int
inline namespace chinmayajha {
#define vi vector<int>
#define vli vector<lli>
#define vii vector<pair<int, int>>
#define vlii vector<pair<lli, lli>>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define sz(x) (int)(x).size()
#define newl cout << "\n";
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inarr(a, n) \
for (int i = 0; i < n; ++i) \
cin >> a[i];
#define rep(i, begin, end) for (int i = begin; i < end; ++i)
#define ceilldiv(x, y) (x + y - 1) / y
const lli MOD = 1000000007;
const ll inf = 1e17;
const long double PI = 3.141592653589793;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
///////////////////////////////////////////////////////////////
template <typename T> T GCD(T a, T b) {
if (!a || !b) {
return a | b;
}
unsigned shift = __builtin_ctz(a | b);
a >>= __builtin_ctz(a);
do {
b >>= __builtin_ctz(b);
if (a > b) {
swap(a, b);
}
b -= a;
} while (b);
return a << shift;
}
template <typename T> T lcm(T a, T b) { return a * (b / GCD(a, b)); }
lli binpow(lli a, lli b) {
lli res = 1;
while (b > 0) {
if (b & 1) {
res = res * a;
}
a = a * a;
b >>= 1;
}
return res;
}
void usaco(string name) {
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
string tostring(int number) {
stringstream ss;
ss << number;
return ss.str();
}
int toint(const string &s) {
stringstream ss;
ss << s;
int x;
ss >> x;
return x;
}
template <class T> T ckmin(T &a, const T &b) {
if (a < b) {
return a;
} else {
return b;
}
}
template <class T> T ckmax(T &a, const T &b) {
if (a > b) {
return a;
} else {
return b;
}
}
} // namespace chinmayajha
using namespace chinmayajha;
bool t_cases = 0;
int cnt, n, m, p, q, r;
string s;
void solve() {
//
cin >> n >> p >> q;
// p before and q after
vi a(n + 14);
rep(i, 0, 7) {
a[i] = INT_MAX;
a[n + 7 + i] = INT_MAX;
}
rep(i, 0, n) { cin >> a[i + 7]; }
// rep(i, 0, int(a.size())) cout << i << " " << a[i] << endl;
rep(k, 7, n + 7) {
// cout << "HULA " << k << " " << a[k] << "> " << a[k - (p != 0)] << " "
// << a[k + (q != 0)] << endl;
if (a[k] > min(a[k - (p != 0)], a[k + (q != 0)])) {
continue;
}
// cout << "HULA " << k << " " << a[k] << endl;
////////////////////////////////////////
bool check1 = 1, check2 = 1;
rep(i, 1, p + 1) {
if (a[k] > a[k - i]) {
check1 = 0;
break;
}
}
if (check1 == 0)
continue;
rep(i, 1, q + 1) {
if (a[k] > a[k + i]) {
check2 = 0;
break;
}
}
if (check2 == 0)
continue;
// cout << "reached check2" << endl;
cout << k - 6;
return;
}
}
int main() {
cin.tie(nullptr);
cout.tie(nullptr);
ios::sync_with_stdio(false);
// usaco("");
int ttt = 1;
if (t_cases) {
cin >> ttt;
}
for (int zxc = 1; zxc <= ttt; zxc++) {
solve();
}
return 0;
}