Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import java.util.StringTokenizer;
import j... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.util.*;
import java.io.*;
import java.lang.*;
public class D{
static int n,a[],L[],R[],res[];
static void MainMethod()throws Exception{
n=reader.nextInt();
a=new int[n+2];
Arrays.fill(a, 0);
res=new int[n+2];
L=new int[n+2];
R=new int[n+2];
int i,j,k;
for (i=1;i<=n;i++) a[i]=reader.next... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int lsone(int n) { return (n & -n); }
void mult(long long int a[25][25], long long int b[25][25],
long long int c[25][25], int m, int n, int p) {
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= p; j++) {
c[i][j] = 0;
for (int k = 1; k <= n; k... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Stack;
import java.util.Vector;
import java.util.Comparator;
import java.io.InputStream;
/**
*... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int partial[200005];
map<int, int> power;
stack<pair<int, int> > store;
int ans[200005];
vector<pair<int, int> > lefty(200005), righty(200005);
int main() {
int n, a;
cin >> n;
for (int i = 0; i < n; i++)... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[200000];
int ans[200000], tree[500000], lazy[500000];
set<int> s;
int n;
set<int>::iterator it;
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i].first;
arr[i].second = i;
}
sort(arr, arr + n... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.IOException;
import java.util.InputMismatchException;
import java.util.Stack;
public class D {
void run() {
MyScanner sc = new MyScanner();
int n = sc.nextInt();
int[] a = sc.nextIntArray(n);
int[] l = new int[n];
int[] r = new int[n];
Stack<Integer> s = new Stack<Integer>();
for (int ... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-9;
int cases = 1;
double getdist(pair<int, int> a, pair<int, int> b) {
return sqrt(pow((double)a.first - b.first, 2) +
pow((double)a.second - b.second, 2));
}
const int MAX = 200000 + 5;
int arr[MAX], ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = (1e5 + 100) * 2;
int a[maxn], ans[maxn];
int l[maxn], r[maxn];
int n, mm, mx;
int main() {
while (~scanf("%d", &n)) {
mm = 0;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
mm = min(a[i], mm);
}
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
const int MAX = 2e5 + 11;
using namespace std;
int N, A[MAX], P[MAX], SZ[MAX], R[MAX];
vector<pair<int, int>> E;
static int get(int x) { return P[x] = (x == P[x]) ? x : get(P[x]); }
static void add(int x, int y, int w) {
int a = get(x);
int b = get(y);
if (a == b) {
return;
}
if (... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.writ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
struct T {
vector<UL> n;
UL Sz;
T(UL sz) {
Sz = 1;
while (Sz < sz) Sz <<= 1;
n.resize(Sz * 2 - 1);
}
void upd(UL p, UL v) {
n[p] += v;
if (p != 0) upd((p - 1) >> 1, v);
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
long long int n;
long long int a[N], L[N], R[N], res[N];
stack<long long int> s;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (long long int i = 1; i <= n; ++i) {
cin >> a[i];
R[i] =... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mx = 10e6 + 5;
int a[mx], ans[mx], l[mx], r[mx];
stack<int> s;
void solve() {
int n;
cin >> n;
for (int i = 0; i <= n - 1; i++) cin >> a[i];
for (int i = 0; i < 1000000; i++) l[i] = -1, r[i] = n;
for (int i = 0; i < n; i++) {
while (!s.empty() && a[s... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
stack<int> stk;
int a[maxn], dpl[maxn], dpr[maxn], ans[maxn];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n; i++) {
while (!stk.empty() && a[stk.top()] >= a[i]) stk.pop(... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 200010;
int n, cnt;
int a[N], s[N], pre[N], las[N];
int mx[N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n; i++) {
while (cnt && a[i] <= a[s[cnt]]) cnt--;
pre[i... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class Feet {
void solve() {
int n = in.nextInt();
int[] A = new int[n];
for (int i = 0; i < n; i++) A[i... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long double pi = acos(-1.0);
long long int power(long long int x, long long int y) {
long long int temp;
if (y == 0) return 1;
temp = power(x, y / 2);
if (y % 2 == 0)
return (temp * temp);
else {
if (y > 0)
return (((x * temp)) * temp);
else
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int &x : a) cin >> x;
vector<int> smaller_left(n, 0), smaller_right(n, n - 1);
priority_queue<pair<int, int> > pq;
for (int i = 0; i < n; ++i) {
while ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int a[1000010], l[1000010], r[1000010], res[1000010];
stack<int> s;
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
while (!s.empty() && a[s.top()] >= a[i]) s.pop();
if (!s.empty())
l[i... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int arr[200015];
pair<int, int> Stack[200015];
int N;
int cur = 0;
int Left[200015];
int Right[200015];
pair<int, int> Ran[200015];
bool first = false;
inline void input() {
for (int i = 1; i <= N; i++) cin >> arr[i];
}
inline void build() {
cur = 0;
Stack[cur++] = ma... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
struct Node {
int num, val;
} nums[200005];
int stc[200005], top = 0, ans[200005];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
scanf("%d", &nums[i].num);
}
for (int i = 1; i <= n; i++) {
while (nums[stc[top]].num >= nums[i].num) {
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mxs = 2e5 + 7;
int n;
int a[mxs];
int l[mxs];
int r[mxs];
int ans[mxs];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = n; i; i--) {
l[i] = i;
while (a[i] <= a[l[i] + 1]) l[i] = l[l[i] + 1];
}
for (int ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
long long gcd(long long x, long long y) {
return y % x == 0 ? x : gcd(y % x, x);
}
template <class T>
T my_abs(T a) {
if (a < 0) a = -a;
return a;
}
const int maxn = 2e5 + 7;
int a[maxn], l[maxn], r[maxn], n, ans[maxn];
int main() {
scanf("%d", &n);
for (int i = (int)(1); i <= (int)(n... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int v[MAXN], l[MAXN], r[MAXN];
int ST[4 * MAXN];
int L[4 * MAXN];
int n;
void _update(int node, int lo, int hi, int i, int j, int val) {
if (L[node]) {
ST[node] = max(ST[node], L[node]);
if (hi != lo) {
L[2 * node] = max(L[node], L[2... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.FileInputStream;
import java.io.*;
import java.util.Locale;
import java.util.StringTokenizer;
public class Task_Rnd305_D {
public static void main(String[] args)
{
reader.init(true); ///!!!
run();
wr.flush();
}
public static void run()
{
int n = reader.nextInt();
int aa[] = new i... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | //package codeforces.round305div2;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public cl... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> Segm_tree(9e5, -2000000000);
void change(int l, int r, int pos, int val, int v) {
if (pos < l || pos >= r) {
return;
}
if (l == r - 1 && l == pos) {
Segm_tree[v] = val;
return;
}
int mid = (l + r) / 2;
change(l, mid, pos, val, 2 * ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.*;
import java.util.*;
import java.math.*;
public class D {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n = Integer.parseInt(in.readLine());
int[] a = new int[n];
st = new String... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 7;
int n, s[N], ans[N];
int main() {
while (cin >> n) {
memset(ans, 0, sizeof(ans));
for (int i = 0; i < n; i++) scanf("%d", &s[i]);
s[n] = 0;
stack<int> st;
int i = 0;
while (i <= n) {
if (st.empty() || s[st.top()] < ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
pair<int, int> A[200005];
int ata[200005], H[200005], S[200005], ans[200005];
int n, i, last, q;
int atabul(int x) {
if (ata[x] == x) return x;
return atabul(ata[x]);
}
int merge(int x) {
S[x] = 1;
if (H[x - 1]) {
S[x] += S[atabul(x - 1)];
ata[atabul(x - 1)]... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
public class Main {
static class Element implements Comparable<Element> {
public int data;
public int index;
public Element(int data, int index) {
th... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.util.*;
import java.io.*;
public class B547 {
public static void main(String[] args) throws IOException
{
FS input = new FS(System.in);
int n = input.nextInt();
int[] data = new int[n];
for(int i = 0; i<n; i++) data[i] = input.nextInt();
int[] stk = new int[n+1];
int[] right = new in... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
import java.util.StringTokenizer;
public class Abood2C {
public static void main(String[] args) throws IOException {
Scanner sc = new Scan... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | from sys import stdin, stdout
def input(): return stdin.readline().strip()
def print(x, end='\n'): stdout.write(str(x) + end)
n, lst = int(input()), list(map(int, input().split()))
nse, pse, stk, ans = [n for i in range(n)], [-1 for i in range(n)], [], [0 for i in range(n+1)]
for i in range(n):
while stk and lst[s... | PYTHON3 |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
T in() {
char ch;
T n = 0;
bool ng = false;
while (1) {
ch = getchar();
if (ch == '-') {
ng = true;
ch = getchar();
break;
}
if (ch >= '0' && ch <= '9') break;
}
while (1) {
n = n * 10 + (ch - '0');
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | // package div2_D;
import java.io.PrintWriter;
import java.util.*;
public class Mike_and_feet {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
long[][] arr = new long[n+2][3];
int[] r = new int[n+2];
int[] ... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class MikeFeet {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.i... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | from sys import stdin, stdout
def input(): return stdin.readline().strip()
def print(x, end='\n'): stdout.write(str(x) + end)
n, lst = int(input()), list(map(int, input().split()))
nse, pse, stk, ans = [n for i in range(n)], [-1 for i in range(n)], [], [0 for i in range(n)]
for i in range(n):
while stk and lst[stk... | PYTHON3 |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
int n;
long long a[2 * N], b[2 * N], c[2 * N], d[2 * N];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
int j = i - 1;
while (a[j] >= a[i]) {
j = b[j];
}
b[i... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void g(int &xx) {
int x = 0;
int f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + ch - '0';
ch = getchar();
}
xx = x * f;
}
int n, a... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void smain();
int main() {
smain();
return 0;
}
const long long INF = 10000000000;
struct sNode {
sNode *left, *right;
long long val, min, max;
} nodes[1000000];
long long nodesCnt = 0;
sNode* addNode() {
sNode* node = nodes + nodesCnt;
node->left = 0;
node->r... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
pair<int, int> v[200005];
int parent[200005];
bool vis[200005];
int cnt[200005];
int ans[200005];
int find(int u) { return (parent[u] == u) ? u : parent[u] = find(parent[u]); }
void Union(int u, int v) {
int pu = find(u), pv = find(v);
if (pu == pv) return;
parent[pu]... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long int inf = 9e18;
void __print(long long int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x)... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, m[200010];
set<int> s;
struct P {
int i, x;
bool operator<(const P& p) const { return x < p.x; }
} p[200010];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
p[i].i = i;
p[i].x = x;
}
sort(&p[1... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, a[200009];
int l[200009], r[200009], ans[200009];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
a[0] = 0;
a[n + 1] = 0;
l[0] = 0;
r[n + 1] = n + 1;
for (int i = 1; i <= n; i++) {
l[i] = i - 1;
while (a[l[i]] >= a[i]) l[... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long arr[200500], pos[200500];
int l[200500], r[200500];
int main() {
int n;
cin >> n;
vector<int> vec;
for (int i = 0; i < n; i++) {
scanf("%lld", &arr[i]);
l[i] = -1;
r[i] = n;
}
for (int i = 0; i < n; i++) {
if (!vec.empty()) {
whil... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Linked... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
public class P548D {
private static List<Integer> getLeft(int... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | /*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
impor... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class B
{
static InputReader in=new InputReader(System.in);
static OutputWriter out=new OutputWriter(System.out);
static StringBuilder sb=new StringBuilder();
static long MOD = (long)(1e9+7);
static long IM2 = (long)(500000... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int a[n + 1];
for (int i = 0; i < n; i++) cin >> a[i];
int ans[n + 1], left[n + 1], right[n + 1];
for (int i = 0; i <= n; i++) ans[i] = 0, left[i] = -1, right[i] = n;
st... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.*;
/**
* Created by yujiahao on 5/2/16.
*/
public class cf_305_d {
private FastScanner in;
private PrintWriter out... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 210000, L = 21;
int t[4 * MAXN];
int a[MAXN];
int bin[MAXN];
int mn[MAXN][L];
int n;
void build(int i) {
mn[i][0] = a[i];
for (int j = 1; j < L; j++) {
if (i + (1 << (j - 1)) < n) {
mn[i][j] = min(mn[i][j - 1], mn[i + (1 << (j - 1))][j - 1]);
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.util.*;
import java.io.*;
import java.math.*;
import java.util.LinkedList;
public class Sample implements Runnable
{
public static void solve()
{
int n=i();
int[] a=new int[n+1];
int[] left=new int[n+1];
int[] right=new ... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200005;
int l[MAX_N], r[MAX_N];
int a[MAX_N];
int n;
int F[MAX_N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n; i++) {
l[i] = i;
while (a[l[i] - 1] >= a[i]) l[i] = l[l[i] - 1];
}
f... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;
/**
* Created by andywu on 5/26/15.
*/
public class TaskD {
public static void main(String[] args){
new TaskD().solve(new Scanner(System.in), System.out);
}
class R implements Comparable<R>{
... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, inf = 0x3f3f3f3f;
int n, top = 0, a[N], s[N];
int le[N], rg[N], ans[N];
priority_queue<pair<int, int> > q;
void solve() {
int R = 0;
while (!q.empty() && R < n) {
pair<int, int> u = q.top();
q.pop();
int val = u.first, p = u.second;
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.StringTokenizer;
public class D {
private static class Solution implements Runnable {
private static final long modulo = 1000000007;
private void solve() {
int n = in.nextInt();
int... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 200005;
int n, l, r, ans[MAXN];
struct X {
int v;
int w;
} num[MAXN];
int main() {
int nmin = INF, nmax = -INF;
cin >> n;
for (int i = 0; i < n; i++) {
scanf("%d", &num[i].v);
num[i].w = 1;
}
memset(ans, -1,... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 500;
int n;
int h[maxn];
int maxarrive[maxn];
int idx[maxn];
int s[maxn];
int maxlength[maxn];
int top = 0;
int main(int argc, char *argv[]) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &h[i]);
int minnum = h[1];
for (int i = 1;... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, a[200005], l[200005], r[200005], ans[200005] = {0};
int main() {
ios_base::sync_with_stdio(false);
cin >> n;
fill(l, l + n + 2, -1);
fill(r, r + n + 2, n);
for (int i = 0; i <= n - 1; i++) cin >> a[i];
stack<int> s;
for (int i = 0; i <= n - 1; i++) {
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int n;
void solve() {
cin >> n;
vector<long long int> height(n);
for (int i = 0; i < n; ++i) {
cin >> height[i];
}
vector<long long int> leftRange(n, -1);
vector<long long int> rightRange(n, n);
vector<long long in... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int &x : a) cin >> x;
vector<int> smaller_left(n, 0), smaller_right(n, n - 1);
priority_queue<pair<int, int> > pq;
for (int i = 0; i < n; ++i) {
while ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 * 2 + 10;
stack<int> s;
vector<int> v;
pair<int, int> p[MAXN];
int a[MAXN];
int ans[MAXN];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
p[i].f... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int getint() {
int t = 0, flag = 1;
char c = getchar();
while (c < '0' || c > '9' || c == '-') {
if (c == '-') flag = -1;
c = getchar();
}
while (c >= '0' && c <= '9') t = t * 10 + c - '0', c = getchar();
return t * flag;
}
int... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | /*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
impor... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long n;
long long arr[200005];
long long rt[200005], sizee[200005];
long long mark[200005];
long long maxsize = 0;
long long root(long long i) {
while (rt[i] != i) {
rt[i] = rt[rt[i]];
i = rt[i];
}
return i;
}
void merge(long long A, long long B) {
long... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
stack<pair<int, int>> st1, st2;
int b[300000], c[300000], a[300000], d[300000], e[300000], f[300000];
void st(int n) {
int i = 0;
st1.push(make_pair(a[0], i));
b[0] = 0;
i = 1;
while (i < n) {
if (st1.top().first < a[i])
st1.push(make_pair(a[i], i)), b[i... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long MaX = 100005, infi = 1110111110111, mod = 1000000007;
const int MX = 200005;
long long n;
vector<int> org(MX);
map<long long, long long> ans, pr;
stack<long long> ST;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> l(n, -1), r(n, n);
stack<int> s, k;
for (int i = 0; i < n; i++) {
while (!s.empty() && a[s.top()] >= a[i]) s.pop();
if (!s.empty()) {
l... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], ans[N], l[N], r[N];
int n;
void input() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
}
int main() {
ios_base::sync_with_stdio(false);
input();
fill(l + 1, l + 1 + n, 0);
fill(r + 1, r + 1 + n, n + 1);
memset(ans, 0, s... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void solve(const vector<int>& xs) {
stack<int> s;
auto n = xs.size();
vector<int> ls(n, -1);
vector<int> rs(n, n);
for (auto i = 0; i < n; ++i) {
while (!s.empty() && xs[s.top()] >= xs[i]) {
s.pop();
}
if (!s.empty()) {
ls[i] = s.top();
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long int par[1234567];
long long int sz[1234567];
bool vis[1234567];
long long int Find(long long int u) {
if (par[u] == -1) return u;
return par[u] = Find(par[u]);
}
void Merge(long long int u, long long int v) {
long long int pu = Find(u), pv = Find(v);
par[p... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int arr[200015];
pair<int, int> Stack[200015];
int N;
int cur = 0;
int Left[200015];
int Right[200015];
pair<int, int> Ran[200015];
bool first = false;
inline void input() {
for (int i = 1; i <= N; i++) cin >> arr[i];
}
inline void build() {
cur = 0;
Stack[cur++] = ma... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3fLL;
const int N = 200005;
int min_to_left[N], min_to_right[N], stk[N];
int arr[N], n, ans[N];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
const int maxv = 1000000010;
int a[maxn];
int l[maxn], r[maxn];
int rj[maxn];
stack<int> s;
int main() {
int n;
cin >> n;
a[0] = 0;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
a[n + 1] = 0;
s.push(0);
for (int i = 1; i < n + 1; i+... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | # import math,string,itertools,fractions,heapq,collections,re,array,bisect
# from itertools import chain, dropwhile, permutations, combinations
# from collections import defaultdict
def VI(): return list(map(int,input().split()))
def main_old(n,a):
s = list(a)
print(max(a),end=" ")
for i in range(1,n):
... | PYTHON3 |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.util.*;
public class Codeforces305D {
static int max(int a,int b){
return a>b?a:b;
}
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int arr[]=new int[n],l[]=new int[n],r[]=new int[n],ans[]=new int[n];
for(int i=0;i<n;i++)
... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn], l[maxn], r[maxn], ans[maxn];
stack<int> s;
int main() {
memset(a, 0, sizeof(a));
memset(l, 0, sizeof(l));
memset(r, 0, sizeof(r));
memset(ans, 0, sizeof(ans));
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int l[maxn], r[maxn], ord[maxn];
int a[maxn], ans[maxn], vis[maxn];
bool cmp(int i, int j) { return a[i] > a[j]; }
int find_l(int x) {
if (!vis[l[x] - 1])
return l[x];
else {
return l[x] = find_l(l[x] - 1);
}
}
int find_r(int x) {
if... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 9;
bool vis[MAX];
int ans[MAX];
bool cmp(pair<int, int> A, pair<int, int> B) { return A.first > B.first; }
int main(void) {
int n, last = 0, mx = -1;
scanf("%d", &n);
vector<pair<int, int> > v(n), ar(n);
for (int i = 0; i < n; i++) {
int in... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;
import java.util.StringTokenizer;
public class MikeAndFeet {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(ne... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | n=int(input())
l=[int(i) for i in input().split()]
stack=[]
ans=[0]*n
left=[-1]*n
right=[n]*n
for i in range(n):
while(stack!=[] and l[i]<=l[stack[-1]]):
stack.pop()
if(stack!=[]):
left[i]=stack[-1]
stack.append(i)
stack=[]
for i in range(n-1,-1,-1):
while(stack!=[] and l[i]<=l[stack[-1]... | PYTHON3 |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
/**
*
* @author sultan.of.swing
*/
public class TaskD {
public FasterScanner mFScanner;
public PrintWriter mOut;
private int sz[];
private int parent[];
publ... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int l[200005], a[200005], mn[200005], n, ans[200005], mnmn = 1e9 + 10;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
mnmn = min(mnmn, a[i]);
}
stack<pair<int, int> > st;
st.push(make_pair(n, a[n]));
for (int i = n - 1; i >= 1;... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.*;
import java.util.*;
public class Codeforces
{
public static void main(String args[])throws Exception
{
BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb=new StringBuilder();
int n=Integer.parseInt(bu.readLine());
String s[... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, a[N], ans[N], lef[N], rig[N];
stack<int> st;
void input() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}
void solve() {
memset(ans, 0, sizeof(ans));
for (int i = 1; i <= n; i++) lef[i] = 0;
for (int i = 1; i <= ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, ans;
int v[200009], d[200009];
pair<int, int> info[200009];
vector<int> st;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> v[i];
while (!st.empty() && v[i] < v[st.back()])
info[st.back()].second = i, st.pop_back();
if (st.empty())
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
vector<int> Left, Right;
void build(vector<int>& A) {
Left.resize(A.size());
Right.resize(A.size());
stack<int> S;
S.push(0);
for (int i = 1; i < A.size(); i++) {
int x = S.top();
if (A[i] >= A[x])
S.push(i);
else {
while (!S.empty() && A[S... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int pri[200050];
int que[200050];
int ans[200050];
int l[200050];
int r[200050];
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 1; i <= n; i++) {
scanf("%d", &pri[i]);
ans[i] = 0;
l[i] = r[i] = 1;
}
int s = 1, e = 0;
... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s;
vector<int> solve(vector<int> &arr, int lo, int hi) {
if (lo > hi) return vector<int>();
if (lo == hi) {
vector<int> ans;
ans.push_back(arr[lo]);
return ans;
}
int mid = (lo + hi) / 2;
vector<int> left = solve(arr, lo, mid);
vector<int> rig... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n;
int dp[200001][17];
int a[200001];
int ans[200001];
void init() {
for (int i = 0; i < n; ++i) {
dp[i][0] = a[i];
}
for (int j = 1; j < 17; ++j) {
for (int i = 0; i < n; ++i) {
dp[i][j] = min(dp[i][j - 1], dp[min(i + (1 << (j - 1)), n - 1)][j - 1])... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
int n, a;
vector<int> input;
int l[200000];
int r[200000];
int... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, ans;
int v[200009], T[4 * 200009];
pair<int, int> info[200009];
vector<int> st;
void upd(int a, int b, int san, int l, int r, int node) {
if (a <= l && b >= r) {
T[node] = max(san, T[node]);
return;
}
if (a > r || b < l) return;
upd(a, b, san, l, (l +... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.util.Arrays;
import java.util.TreeSet;
import java.io.Inpu... | JAVA |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
vector<long long> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
vector<long long> l(n + 1, 0);
vector<long long> r(n + 1, 0);
stack<long long> q;
for (int i = 1; i <= n; i++) {
while (q.size() != 0 && a[q.top()] ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
int parent[int(5e5) + 10], size[int(5e5) + 10];
int a[int(5e5) + 10], ans[int(5e5) + 10], vis[int(5e5) + 10],
valu[int(5e5) + 10];
pair<int, int> p[int(5e5) + 10];
void make_set(int v) {
parent[v] ... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mxN = 2e5 + 5;
int n, a[mxN], l[mxN], r[mxN], ans[mxN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
stack<int> s;
for (int i = 0; i < n; ++i) {
while (!s.empty() && a[s.top()] >= a[i]) s.pop(... | CPP |
548_D. Mike and Feet | Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high.
<image>
A group of bears is a non-empty contiguous segment of the line. The size of ... | 2 | 10 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T>
inline void scan_d(T &ret) {
char c;
int flag = 0;
ret = 0;
while (((c = getchar()) < '0' || c > '9') && c != '-')
;
if (c == '-') {
flag = 1;
c = getchar();
}
while (c >= '0'... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.