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
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(raw_input()) x = map(int,raw_input().split()) f = lambda l,r:(l,r) if l<=r else (r,l) for i in range(n-1): (l,r) = f(x[i],x[i+1]) for j in range(i+1,n-1): (u,v) = f(x[j],x[j+1]) if not(r<=u or v<=l or u<=l<=r<=v or l<=u<=v<=r): print "yes" exit(0) print "no" ...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
def check(a,b): if min(a)<min(b)<max(a)<max(b) or min(b)<min(a)<max(b)<max(a): return True else: return False lo = False n = int(input()) l = list(map(int, input().split())) coppie = [] for cont in range(0,n-1): coppie.append(list((l[cont],l[cont+1]))) for c in range(0,len(coppie)-1): for d in range(c+1,l...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; if (n <= 3) { cout << "no" << endl; return 0; } else { for (i...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); long x; cin >> x; long long *arr = new long long[x]; for (long i = 0; i < x; i++) { cin >> arr[i]; } int c = 0; for (long i = 0; i < x - 1; i++) { for (long j = 0; j < x - 1; j++) { ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 4; int a[N]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { int x = 0; int y = 0; for (int j = i + 2; j < n; j++) if ((a[j] > a[i] && a[j] > a[i + 1]) || (a[j] < a[i] && a[j]...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) arr = list(map(int, input().split())) for i in range(n-2): for j in range(i+1, n-1): a = sorted([sorted([arr[i], arr[i + 1]]), sorted([arr[j], arr[j + 1]])]) if a[1][0] > a[0][0] and a[1][0] < a[0][1] and a[1][1] > a[0][1]: print('yes') exit() print('no')
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) cord = list(map(int,input().split())) check = 0 for i in range(n-1): a,b = cord[i],cord[i+1] if a>b: a,b = b,a for j in range(n-1): x,y = cord[j],cord[j+1] if x>y: x,y = y,x if (a<x and b>x and b<y) or (a>x and a<y and b>y): print('yes...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
from math import sqrt def mi():return map(int,input().split()) def li():return list(mi()) def ii():return int(input()) def si():return input() n=ii() a=li() f=0 for i in range(1,n-1): x=min(a[i],a[i+1]) y=max(a[i],a[i+1]) for j in range(i): if(a[j]>x and a[j]<y): if(j-1>=0): ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) a=list(map(int,input().split())) b=a[:] b.sort() ok=0 c={} g={} for i in range(n-1): l,r=b.index(a[i]),b.index(a[i+1]) c[b[l]]=r g[r]=l for i in range(n-1): if not b[i] in c:continue if i>c[b[i]]:l,r=c[b[i]],i else:l,r=i,c[b[i]] for j in range(l+1,r): if b[j]...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; struct bla { int comeca; int fim; bla() { comeca = 0; fim = 0; } }; vector<bla> v; bool mysort(bla a, bla b) { if (a.comeca != b.comeca) { return a.comeca < b.comeca; } return a.fim < b.fim; } int main() { bool pode; int n, s, e, m; scanf("%d...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) x = list(map(int, input().split())) for i in range(n - 1): a = sorted((x[i], x[i + 1])) for j in range(i): b = sorted((x[j], x[j + 1])) if b[0] < a[0] < b[1] < a[1] or a[0] < b[0] < a[1] < b[1]: print("yes") exit() print("no")
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int a[1010]; bool check(int a, int b, int c, int d) { if (a > b) swap(a, b); if (c > d) swap(c, d); if (c > a && c < b && (d < a || d > b)) return 1; if (d > a && d < b && (c < a || c > b)) return 1; if (a > c && a < d && (b < c || b > d)) return 1; if (b > c &&...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean yes = false; int start [] = new int [n]; int end [] = new int [n]; if(n>1){ int x1 = sc.nextInt(), x2 = sc.nextInt(); start[0] = x1; end [0] = x2; for...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; import java.io.*; public class Main implements Runnable { public void solve() throws IOException { int N = nextInt(); int[] arr = new int[N]; for(int i = 0; i < N; i++) arr[i] = nextInt(); boolean intersect = false...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; public class A { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int b = sc.nextInt(); int[] table1 = new int[n-1]; int[] table2 = new int[n-1]; boolean yes = false; for(int i = 0; i<n-1; i++){ int a = b; b = sc.nextInt...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int dr[] = {1, 0, -1, 0, -1, -1, 1, 1}; int dc[] = {0, -1, 0, 1, -1, 1, -1, 1}; const int MAX = 1e6 + 7; const int MOD = 1e9 + 7; int arr[MAX]; int main() { int a, b, c, d, n, f = 0; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; a = arr[0], b = arr[1]; for ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n; cin >> n; vector<long long int> v(n); if (n == 1) { cout << "no" << endl; return 0; } for (long long int i = 0; i < n; i++) { cin >> v[i]; } vector<pai...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; public class Main{ public static void main(String[] args){ Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] a = new int[n]; for(int i = 0; i<n; i++) a[i] = s.nextInt(); int x, xx, y, yy; for(int i = 0; i + 1 < n; i++){ ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; import java.io.*; public class File { public static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st =...
JAVA
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int T = 60, maxn = 3e5 + 5; struct node { int id, val; } a[maxn]; int n; int pre[maxn], nxt[maxn]; bool cmp(node a, node b) { return a.val == b.val ? a.id < b.id : a.val < b.val; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 300005; int n; struct Node { int pos, v; } a[N]; int pre[N], nxt[N]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].v, a[i].pos = i; sort(a + 1, a + n + 1, [](Node a, Node b) { return a.v < b.v; }); for...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 300010; set<int> S; vector<int> vr[maxn]; vector<int> vl[maxn]; int a[maxn]; struct NN { int ind, val; } nn[maxn]; int cmp(NN a, NN b) { return a.val < b.val; } long double arr[110]; int main() { int n, i, j, k; for (arr[0] = 1, i = 1; i <= 30; i++) a...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; long long int N; double er[300020], fr[300020], bk[300020], ans; pair<double, int> ar[300020]; set<int> asd; int main() { scanf("%lld", &N); for (int i = 1; i <= N; i++) scanf("%lf", &er[i]), ar[i] = pair<double, int>(er[i], i); sort(ar + 1, ar + N + 1); reverse...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.stream.IntStream; import java.util.Arrays; import java.util.Random; import java.util.ArrayList; import java.math.BigDecimal; import java.io.OutputStreamWriter; import java.io.OutputStream; import java.io.IOException; i...
JAVA
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int n, a[300010]; void read() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", a + i); } double work() { static int prev[300010], next[300010]; static pair<int, int> v[300010]; for (int i = 1; i <= n; ++i) v[i] = make_pair(a[i], i), prev[i] = i - 1,...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; set<int> s; int a[300300]; pair<int, int> b[300300]; int n; bool cmp(const pair<int, int> &a, const pair<int, int> &b) { if (a.first > b.first) return (true); if (a.first < b.first) return (false); return (a.second < b.second); } void init(void) { scanf("%d", &n); ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse3", "sse2", "sse") #pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3") #pragma GCC target("f16c") #pragma GCC optimize("inline", "fast-math", "unroll-loops", \ "no-stack-protector") using namespace std; templat...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; const int S = 21; int n, b[MAXN]; int lp[MAXN], rp[MAXN], x; vector<pair<int, int> > q; double ans = 0; void init() { for (int i = 0; i <= n; i++) { lp[i + 1] = i; rp[i] = i + 1; } b[0] = MAXN; b[n + 1] = MAXN; } int findL(int i) {...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.util.Locale; import java.util.Comparator; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper p...
JAVA
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; template <class T> inline T sqr(T x) { return x * x; } const double EPS = 1e-6; const int INF = 0x3fffffff; const long long LINF = INF * 1ll * INF; const double PI = acos(-1.0); using namespace std; int faL[300005], faR[300005]; int a[300005]; pair<int, int> p[300005]; in...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 300010; int n, a[maxn], r[maxn]; bool cmp(int x, int y) { if (a[x] != a[y]) return a[x] > a[y]; return x < y; } double L[maxn], R[maxn]; double two[maxn]; int main() { two[0] = 1; for (int i = 1; i < maxn; i++) two[i] = two[i - 1] / 2; scanf("%d",...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int b[300010], p[300010], l[300010], r[300010]; bool cmp(int i, int j) { return b[i] < b[j]; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &b[i]); p[i] = i; l[i] = i - 1; r[i] = i + 1; } sort(p + 1, p + n + 1, cm...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 300005; const int inf = 1e9 + 7; int a[N], pos[N]; int pre[N], nxt[N]; inline bool cmp(const int &x, const int &y) { return a[x] < a[y]; } int main() { int n; scanf("%d", &n); for (int i = (1); i <= (n); i++) pos[i] = i, pre[i] = i - 1, nxt[i] = i + ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int T = 50; struct Q { int id, v; } a[1000010]; int n; double ans; int nxt[1000010], pre[1000010]; bool cmp(Q a, Q b) { if (a.v == b.v) return a.id < b.id; else return a.v < b.v; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d"...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int main() { cout.precision(20); cout << fixed; ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); vector<double> pow(1000); pow[0] = 1; for (int i = 1; i < 1000; i++) { pow[i] = pow[i - 1] * 2; } int n, k = 40; cin >> n; vector<pair<int, int...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> const int MAXN = 300000 + 100; const int MAXP = 50; std::pair<int, int> lst[MAXN]; int b[MAXN]; int n; double m2[MAXP]; struct node { int sum; double s1, s2; void merge(node a, node b) { sum = a.sum + b.sum; s1 = b.s1; if (b.sum < MAXP) s1 += a.s1 * m2[b.sum]; s2 = a.s2; ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 1 << 19; double pw2[8 * N]; struct mynum { double v; int sh; mynum(double _v, int _sh) { v = _v; sh = _sh; } mynum() {} mynum shift(int x) { return mynum(v, sh + x); } friend mynum operator+(mynum a, mynum b) { if (a.sh < b.sh) swap(a...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; long long powmod(long long a, long long b) { long long res = 1; a %= 1000000007; for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } template <typename T> inline bool chkmin(T...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int b[300010], p[300010], l[300010], r[300010]; bool cmp(int i, int j) { return b[i] < b[j]; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &b[i]); p[i] = i; l[i] = i - 1; r[i] = i + 1; } sort(p + 1, p + n + 1, cm...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; const int LG = 20; const int M = 30; int mx[N][LG]; int a[N]; int n; int pre[M], suf[M]; int prv(int v, int val) { for (int i = LG - 1; i >= 0; i--) if (v - (1 << i) >= 0 && mx[v - (1 << i)][i] < val) v -= (1 << i); return v - 1; } int nxt(int...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; struct node { int s, i; } a[300100]; int l[300100], r[300100], n, i, j; double ans; int gi() { int s = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s; } bool ope...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int ab; int b[300000]; vector<int> ld[300000], rd[300000]; int main() { ios_base::sync_with_stdio(false); cin >> ab; for (int i = 0; i < ab; i++) { cin >> b[i]; b[i] = max(b[i], 0); rd[i].push_back(i); ld[i].push_back(i); } set<pair<int, int> > s; ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 300010; const int TINY = 1e-13; int N; double b[MAXN]; pair<double, int> first[MAXN]; const int MAXS = 25; int Ls, Rs; int L[MAXS], R[MAXS]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout << setprecision...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 400000; struct T { int a; int b; } V[N]; inline bool cmp(T a, T b) { return a.a < b.a; } set<int> S; double p2[41]; int n; int main() { p2[0] = 1; for (int i = (1); i <= (40); i++) p2[i] = p2[i - 1] * 2; scanf("%d", &n); for (int i = (1); i <= (n);...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; int n, m, ans; int a[300005], l[300005], r[300005], fuck[300005], pre[300005]; double p; bool flag; struct fuck { int id, val; bool operator<(const fuck &ls) const { return val > ls.val || (val == ls.val && id < ls.id); } } v[300005]; inline i...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int x[110], y[110]; vector<pair<int, int> > a; set<int> S; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int ret; cin >> ret; a.push_back(make_pair(-ret, i)); } sort(a.begin(), a.end()); double res = 0; for (int i = 0; i < n; i++) { ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } int a[300300], id[300300]; set<int> s; bool cmp(int i, int j) { return a[i] != a[j] ? a[i] > a[j] : i ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const double eps = 1e-9; const int maxn = 3e5 + 10; const int maxT = 100; int a[maxn], nex[maxn], pre[maxn], rk[maxn]; bool cmp(const int &lhs, const int &rhs) { return a[lhs] == a[rhs] ? lhs < rhs : a[lhs] < a[rhs]; } inline int read() { int x = 0,...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 300300; const int MAX = 70; int b[MAXN]; int main(void) { int n; scanf("%d", &n); for (int i = 0; i < (n); ++i) scanf("%d", b + i); static pair<int, int> a[MAXN]; for (int i = 0; i < (n); ++i) a[i] = {b[i], i}; sort(a, a + n, greater<pair<int, i...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int cmp(const pair<int, int> &a, const pair<int, int> &b) { if (a.first != b.first) return a.first > b.first; else return a.second < b.second; } double sv[32 + 10], lenl[32 + 10], lenr[32 + 10], lv[32 + 10], rv[32 + 10]; int a[300010]; pair<int, int> d[300010]; ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; struct Tedge { int to, next; } edge[3333333]; int now, first[333333], data[333333]; multiset<int> Q; int Rand() { return (rand() << 15) | rand(); } void Addedge(int x, int y) { edge[++now].to = y; edge[now].next = first[x]; first[x] = now; return; } int main() { ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MaxN = 300000; int main() { int n; static int a[MaxN + 1]; cin >> n; for (int i = 1; i <= n; i++) scanf("%d", &a[i]); static pair<int, int> ap[MaxN]; for (int i = 1; i <= n; i++) ap[i - 1] = pair<int, int>(a[i], i); sort(ap, ap + n); static int pre...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; typedef double db[1200010]; typedef int arr32[300010]; arr32 x, g; db sz, ur, val1, val2; double p, q, ura; int n; void update(int k, int l, int r) { sz[k] = sz[(k << 1)] * sz[(k << 1) + 1]; val1[k] = val1[(k << 1)] * sz[(k << 1) + 1] + val1[(k << 1) + 1]; val2[k] = v...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; set<int> S; double r[44], ans; int n; pair<int, int> a[333333]; int p[44], q[44]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i].first), a[i].second = i; sort(a + 1, a + 1 + n); S.insert(0), S.insert(n + 1); r[0] = 1; for (int i = 1...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int n, r, LL[300005][28], RR[300005][28]; long long PP[28]; int A[300005]; pair<int, int> P[300005]; set<int> H; set<int>::iterator it; int L[300005][28], R[300005][28]; double res; int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; int i; f...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int K = 30; const int N = 300000; int n, pre[N + 10], nxt[N + 10]; set<int> s; struct data { int va, loc; } a[N + 10]; double ans = 0; bool cmp(data p, data q) { return p.va > q.va; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 3; const long long M = 43; const long long SQ = 320; const long long INF = 1e16; const long long MOD = 1e9 + 7; int n; pair<int, int> a[N]; set<int> st; double v[N][M], v1[N][M]; int c[N], c1[N]; double t[50]; int main() { t[0] = 1; for (int i ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int v[700005], id[700005], L[700005], R[700005], n; double Ans; bool cmp(const int &i, const int &j) { return v[i] < v[j]; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) L[i] = i - 1, R[i] = i + 1; for (int i = 1; i <= n; i++) scanf("%d", &v[i]), id[i] =...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXL = 58; int fw[MAXL + 5], bw[MAXL + 5]; double p2[MAXL * 2 + 5]; pair<int, int> A[300005]; set<int> S; int main() { p2[0] = 1; for (int i = 1; i < MAXL * 2 + 5; ++i) p2[i] = p2[i - 1] / 2; double ans = 0; int N; scanf("%d", &N); for (int i = 1; i <=...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int N, K, K1, K2, nr, a[300009], lft[309], rgt[309]; double ans, put[209]; pair<int, int> v[300009]; set<int> S; int main() { scanf("%d", &N); for (int i = 1; i <= N; i++) scanf("%d", &a[i]), v[i] = make_pair(-a[i], i); put[0] = 1.0; for (int i = 1; i <= 102; i++) p...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int n, a[300005], pre[300005], nxt[300005], c[300005], p0[100], p1[100]; bool cmp(const int &u, const int &v) { return a[u] < a[v]; } double ans = 0, pw[100]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), pre[i] = i - 1, nxt[i] = i +...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 333333; int a[N]; int pos[N]; set<int> s; int n; bool cmp(const int pos1, const int pos2) { if (a[pos1] != a[pos2]) return a[pos1] > a[pos2]; return pos1 < pos2; } double calc(int pos) { set<int>::iterator sit; int prev; double c1 = 0, c2 = 0, two; ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 300005; struct node { int v, id; inline bool operator<(const node &o) const { return v < o.v || (v == o.v && id < o.id); } } p[MAXN]; int n, pre[MAXN], nxt[MAXN]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &p[i]...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int Get() { char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) ; int res = 0; for (; ch >= '0' && ch <= '9'; ch = getchar()) res = res * 10 + ch - '0'; return res; } const int N = (int)1e6; typedef int arr[N + 10]; int n, m, cnt; arr a, ord, nex...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int n; int b[300000]; int indice[300000]; bool compara(int i1, int i2) { return b[i1] < b[i2]; } const int primero = 1 << 19; const int tope = 1 << 20; int cuantos[tope]; double sumari[tope], sumale[tope]; double expo[300000]; void inserta(int pos, int val) { pos += prime...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
//package round222; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class E2 { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); in...
JAVA
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 300100; int ar[MAXN]; int A[MAXN]; int B[MAXN]; pair<int, int> arr[MAXN]; int N; int main() { scanf("%d", &N); for (int i = 1; i <= N; ++i) { scanf("%d", ar + i); arr[i - 1] = pair<int, int>(ar[i], i); } for (int i = 1; i <= N; ++i) { A[...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:60777216") using namespace std; int n; int b[333333]; vector<pair<int, int> > t; int rv[333333]; struct Node { Node *lf; Node *rg; int l, r; int mx; Node() { lf = rg = 0; mx = 0; } }; Node *root; Node *buildTree(int from, int to) { Node *res...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m; int id[300010], f[300010], g[300010]; double b[300010], an; inline bool cc1(const int &A, const int &B) { return b[A] < b[B]; } int getg(int x) { return g[x] == x ? x : g[x] = getg(g[x]); } int getf(int x) { return f[x] == x ? x : f[x] = getf(f[x]); } int...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int N, i, j, B[300010]; pair<int, int> U[300010]; int W[300010]; bool Cmp_pii(pair<int, int> p, pair<int, int> q) { if (p.first != q.first) return (p.first > q.first); else return (p.second < q.second); } const int DEP = 60; long double Rate[DEP + 5], ANS, Lc, R...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int arr[300005], p[300005]; vector<int> left_[300005], right_[300005]; set<int> f; const int MAX = 25; const int UP = MAX + 1; bool cmp(int i, int j) { return arr[i] < arr[j] || arr[i] == arr[j] && i < j; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; +...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.Comparator; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.IOException; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; import jav...
JAVA
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int n; struct jsb { int a, b; } data[310000]; inline bool cmp(const jsb &a, const jsb &b) { return a.a > b.a; } double Pow[310000]; struct Info { double al, ar; int sum; inline Info operator+(const Info &b) const { Info c; c.al = c.ar = c.sum = 0; c.sum ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int T = 100; int rk[N], w[N], n; int nxt[N], pre[N]; bool cmp(int x, int y) { return w[x] ^ w[y] ? w[x] < w[y] : x < y; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &w[i]), rk[i] = i; sort(rk + 1, rk + n + 1, c...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int n, a[300005], b[300005], l[300005], r[300005]; double ans; inline int read() { int x = 0, f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1; for (; isdigit(ch); ch = getchar()) x = (x + (x << 2) << 1) + (ch ^ 48); retur...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 300010; int n, b[N], i, j, l[N], r[N], u, v, p[N], k; double x, y, z, ans; bool cmp(int x, int y) { return b[x] < b[y]; } int main() { scanf("%d", &n); for (i = 1; i <= n; ++i) { scanf("%d", b + i); l[i] = i - 1; r[i] = i + 1; p[i] = i; }...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> int arr[300010], n; std::pair<int, int> idx[300010]; int A[300010], B[300010]; double ans, l, r, pw; int main(void) { int i, x, a, b, now, j; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &arr[i]); idx[i].first = arr[i], idx[i].second = i; } std::sort(idx + 1, idx + ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 312345; pair<int, int> b[maxn]; int n, pre[maxn], nxt[maxn]; int main() { scanf("%d", &n); for (int(i) = (1); (i) <= (n); (i)++) { scanf("%d", &b[i].first); b[i].second = i; } sort(b + 1, b + n + 1); for (int(i) = (1); (i) <= (n); (i)++) n...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 300010; const int TINY = 1e-13; int N; double b[MAXN]; pair<double, int> first[MAXN]; const int MAXS = 30; int Ls, Rs; int L[MAXS], R[MAXS]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout << setprecision...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int key[300005], pos[300005], pre[300005], nxt[300005], n; const int maxj = 35; bool cmp(int x, int y) { return key[x] < key[y]; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &key[i]); pos[i] = i; pre[i] = i - 1; nxt[i] = i +...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 300 * 1000; const int MAXK = 30; const int INF = 1000 * 1000 * 1000; int a[MAXN + 2]; int l[MAXN + 2][MAXK]; int r[MAXN + 2][MAXK]; int cntl[MAXN + 2], cntr[MAXN + 2]; set<pair<int, int> > is; long long two[MAXK + 10]; int main() { ios_base::sync_with_std...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int c = 60; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(20) << fixed; vector<long double> p2(c + 2); p2[0] = 1.; for (int i = 1; i <= c + 1; i++) p2[i] = p2[i - 1] / 2.; int n; cin >> n; vector<pair<int, int> > a(n); ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target( \ "avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; int MOD = 1e9 + 7; const int N = 500000; const int B = 60; set<int> sk; long double pw2[3 * B]; long double solve(int id) { sk.insert(id); vec...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5; int nums[MAXN], b; set<int> s; set<int>::iterator it; double p2[100], tot = 0; pair<int, int> sortn[MAXN]; void calc(int x) { double sr = 0, sl = 0; int prev = x; it = s.lower_bound(x); int ct = 0; while (it != s.end() && ct <= 60) { ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int K = 50; const int N = 300000; int n, pre[N + 10], nxt[N + 10]; set<int> s; struct data { int va, loc; } a[N + 10]; double ans = 0; bool cmp(data p, data q) { return p.va > q.va; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; bool cmax(int &a, int b) { return (a < b) ? a = b, 1 : 0; } bool cmin(int &a, int b) { return (a > b) ? a = b, 1 : 0; } template <typename T> T read() { T ans = 0, f = 1; char ch = getchar(); while (!isdigit(ch) && ch != '-') ch = getchar(); i...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; set<int> S; double pwr[44], ans; int n; pair<int, int> a[333333]; int p[44], q[44]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i].first), a[i].second = i; sort(a + 1, a + 1 + n); S.insert(0), S.insert(n + 1); pwr[0] = 1; for (int i...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; template <class T> inline void smin(T &a, T b) { if (b < a) a = b; } template <class T> inline void smax(T &a, T b) { if (a < b) a = b; } const int maxn = 3 * 100000 + 1000; const int K = 50; int n; pair<int, int> arr[maxn]; set<int> s; vector<int> L[maxn], R[maxn]; int...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; struct pi { int le, ri, ma; } pp[maxn << 2]; void build(int tot, int l, int r) { pp[tot].le = l; pp[tot].ri = r; pp[tot].ma = 0; if (l == r) return; build(2 * tot, l, (l + r) / 2); build(2 * tot + 1, (l + r) / 2 + 1, r); } void merg(in...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 * 3 + 10, M = 60; int n, a[MAXN], id[MAXN], l[MAXN], r[MAXN]; long double Tohka; bool cmp(int first, int second) { return a[first] < a[second]; } int main() { cout << setprecision(10); scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, const U &b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, const U &b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> int inp() { char c = getchar(); while (c < '0' || c > '9') c = getchar(); int sum = 0; while (c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); } return sum; } int a[300010], nxt[300010], pre[300010], id[300010]; bool cmp(int x, int y) { return a[x] < a[y]; } ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int pre[300000 + 5], nxt[300000 + 5]; struct Node { int val; int id; friend bool operator<(Node p, Node q) { if (p.val == q.val) { return p.id < q.id; } return p.val < q.val; } } a[300000 + 5]; int n; int main() { scanf("%d", &n); for (int i = ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; set<int> S; double r[44], ans; int n, p[44], q[44]; pair<int, int> a[333333]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i].first), a[i].second = i; sort(a + 1, a + 1 + n); S.insert(0), S.insert(n + 1); r[0] = 1; for (int i = 1; i ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; int pai[2][300300]; int foi[300300]; int find(int x, int id) { return pai[id][x] = (x == pai[id][x]) ? x : find(pai[id][x], id); } int main() { int n; scanf("%d", &n); vector<pair<int, int> > v; for (int i = 0; i < n; i++) { int u; scanf("%d", &u); v.p...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 300000 + 77, LOG = 70; int n, a[N], L[N], R[N], P[N]; bool CMP(int x, int y) { return a[x] < a[y]; } double A; vector<int> V, T; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", a + i), L[i] = i - 1, R[i] = i + 1, P[i] = i; R[n ...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> const int OO = 0; const int inf = 2e9 + 7; using namespace std; const int lim = 60; int n; vector<pair<int, int>> a; set<int> S; vector<int> R, L; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n; a.resize(n); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].secon...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class Main223E { private FastScanner in; private PrintWriter out; ...
JAVA
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 300010; set<int> S; int vl[maxn][33]; int vr[maxn][33]; int nl[maxn], nr[maxn]; int a[maxn]; struct NN { int ind, val; } nn[maxn]; int cmp(NN a, NN b) { return a.val < b.val; } long double arr[110]; int main() { int n, i, j, k; for (arr[0] = 1, i = 1;...
CPP
380_E. Sereja and Dividing
Let's assume that we have a sequence of doubles a1, a2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation: 1. choose an index of the sequence element i (1 ≀ i ≀ |a|); 2. consecutively perform assignments: <image>. Let's use function g(a, x) to represent the large...
2
11
#include <bits/stdc++.h> using namespace std; template <typename T> void __read(T &a) { cin >> a; } template <typename T, typename... Args> void __read(T &a, Args &...args) { cin >> a; __read(args...); } constexpr long long M7 = 1000000007ll; constexpr long long M9 = 1000000009ll; constexpr long long MFFT = 99824...
CPP