-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0219.cpp
More file actions
35 lines (27 loc) · 736 Bytes
/
0219.cpp
File metadata and controls
35 lines (27 loc) · 736 Bytes
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
// https://coderun.yandex.ru/problem/adventure-time
// greedy + running minimum (prefix minimum) + single pass
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define sz(x) (int)(x).size()
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
vi arr;
int x;
while (cin >> x) arr.push_back(x);
ll max_dif = 0;
int mn = 0;
int rl = 0, rr = 0;
rep (i, 0, sz(arr))
{
if (arr[i] < arr[mn]) mn = i;
else if ((ll)arr[i] - (ll)arr[mn] > max_dif)
{ max_dif = (ll)arr[i] - (ll)arr[mn]; rl = mn; rr = i; }
}
cout << max_dif << " " << rl << " " << rr << "\n";
return 0;
}