prompt string | response string |
|---|---|
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n;
cin >> n;
long long a[n];
for... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Ribhav
*/
public class Mai... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n;
cin >> n;
vector<long long int> a(n), b;
for (long long int i = 0; i < n; i++) cin >> a[i];
for (long long int i = 1; i < n; i++) b.push_back(abs(a[i] - a[i - 1]));
n = b.size();
long long int dp[n][2];
dp[n - 1][0] = b[n - 1]... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int N;
long long a[100000];
void input() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%I64d", &a[i]);
}
}
long long b[100000];
long long c[100000];
long long maxSumSubarr() {
long long sum = c[0];
long long max_sum = sum;
for (int i = 1; i < N - 1... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... |
import java.util.*;
import java.lang.*;
import java.io.*;
public class Prac {
public static long max(long a,long b){
if(a>b)
return a;
else
return b;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class Main {
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | def max_sum(a):
s, ans = 0, 0
for i in a:
s += i
ans = max(s, ans)
s = max(0, s)
return ans
n = int(input())
*a, = map(int, input().split())
a = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
b = [-1 * a[i] if i & 1 else a[i] for i in range(n - 1)]
a = [a[i] if i & 1 else -1 * a[i] for... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long was[211111][2];
int a[211111];
int n;
long long f(int x, int o) {
if (was[x][o]) return was[x][o] - 1;
long long ret = 0;
if (x + 1 < n) {
long long val = f(x + 1, o ^ 1);
if (o == 0)
val += abs(a[x + 1] - a[x]);
else
val -= abs(a[x +... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
arr = list(map(int,input().split()))
even = [0 for i in range(n)]
odd = [0 for i in range(n)]
diff = []
for i in range(n-1):
diff.append(abs(arr[i]-arr[i+1]))
for i in range(len(diff)):
even[i] = max(diff[i],diff[i]+odd[i-1])
odd[i] = max(-diff[i],-diff[i]+even[i-1])
print(max(max(even),max... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | // Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
// Please name your class Main
public class Main {
//static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
/*static int read() throw... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n=int(input())
a=list(map(int,input().split()))
da,p=[],1
for i in range(n-1):
da.append(p*abs(a[i]-a[i+1]));p*=-1
m1,m2,s1,s2=0,0,0,0
for x in da:
s1+=x
if s1<0: s1=0
s2-=x
if s2<0: s2=0
m1=max(m1,s1);m2=max(m2,s2)
print(max(m1,m2))
# Made By Mostafa_Khaled |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
a = list(map(int, input().split()))
first = [-abs(a[i]-a[i-1]) if (i+1)%2 else abs(a[i]-a[i-1]) for i in range(1, n)]
second = [abs(a[i]-a[i-1]) if (i+1)%2 else -abs(a[i]-a[i-1]) for i in range(2, n)]
mx = -10**18
cur = 0
for i in range(len(first)):
cur = first[i] + max(cur, 0)
if i%2 == 0:
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int inf = (int)1e9 + 10;
const int mod = (int)1e9 + 7;
const double eps = 1e-7;
const double pi = 3.14159265359;
const int maxLen = (int)1e5 + 2;
int A[maxLen];
long long D[maxLen];
int main() {
int n;
scanf("%d", &n);
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, i, s = 0, m = 0, x = 0, y = 0, l = 0;
cin >> n;
vector<long long> a(n);
for (i = 0; i < n; i++) cin >> a[i];
for (i = 0; i < n - 1; i++) a[i] = abs(a[i] - a[i + 1]);
for (i = 0; i ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.*;
import java.util.*;
public class test {
int INF = (int)1e9;
long MOD = 1000000007;
void solve(InputReader in, PrintWriter out) throws IOException {
int n = in.nextInt();
long[] a = new long[n];
for(int i=0; i<n; i++) {
a[i] = in.nextInt();
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C789 {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readL... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class CFD {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
final long MOD = 1000L * 1000L * 1000L +... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | from itertools import accumulate
inf = 10**9 + 1
def solve():
n = int(input())
a = [int(i) for i in input().split()]
ad = [abs(a[i + 1] - a[i]) for i in range(n - 1)]
ap = [0] + list(accumulate(ai*(-1)**i for i, ai in enumerate(ad)))
max_dif, min_dif = max_min_profit(ap)
ans = max(max_dif, -m... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll OO = 1e18;
int di[8] = {0, 0, 1, -1, -1, 1, -1, 1};
int dj[8] = {1, -1, 0, 0, 1, 1, -1, -1};
string ys = "YES", no = "NO";
const long double dgr = acos(-1) / 180, dg = 180 / acos(-1);
const int mod = 1e9 + 7, N = 5e5 + ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... |
import java.io.*;
import java.util.*;
public class TestClass
{
static PrintWriter out = new PrintWriter(System.out);
public static void main(String args[]) throws Exception
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
String s[] = in.rea... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.util.*;
import java.io.*;
public class Forces{
public static void main(String ...arg)
{
Read cin = new Read();
int n = cin.nextInt();
Long even[] = new Long[n-1];
Long odd[] = new Long[n-1];
long a = cin.nextLong();
long b = a;
int sign;
long val;
for(int i=0;i<n-1;i++)
{
a = b;... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long a[100010];
long long b[100010];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n - 1; i++) {
b[i] = abs(a[i] - a[i + 1]);
if (i % 2 == 0) b[i] *= -1;
}
long long x = 0, ans = 0;
for (int... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int inf = (int)1e9 + 10;
const int mod = (int)1e9 + 7;
const double eps = 1e-7;
const double pi = 3.14159265359;
const int maxLen = (int)1e5 + 2;
int A[maxLen];
long long D[maxLen];
int main() {
int n;
scanf("%d", &n);
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int N, A[100500];
long long B[100500];
long long tbs[100500], tbb[100500];
long long ans = (long long)-1e18;
int main() {
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%d", &A[i]);
}
for (int i = 1; i < N; i++) {
B[i] = A[i] - A[i + 1];
if (B[i]... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
InputReader inputReader = new InputReader(in);
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
long long getBrute(vector<long long> &a) {
long long n = a.size();
long long ans = -INF;
for (long long l = 0; l < n; l++) {
long long cur = 0;
for (long long r = l + 1; r < n; r++) {
if ((r - l) % 2 == 1) {
cur += abs... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(raw_input())
a = [int(x) for x in raw_input().split()]
def drawdown(l):
cumsum = 0
min_x = 0
answer = 0
for i,val in enumerate(l):
if i%2 == 0:
min_x = min(min_x, cumsum)
cumsum += val
answer = max(answer, cumsum - min_x)
return answer
poso = [abs(a[i]-a[i+1])*(-1)**i for i in range(n-1)]
nego =... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
void fun() {
int n;
cin >> n;
long long a[n];
for (auto &i : a) cin >> i;
vector<long long> s;
for (int i = 1; i < n; i++) s.push_back(abs(a[i] - a[i - 1]));
long long dpn[n - 1], dpp[n - 1];
dpp[0] = s[0];
dpn[0] = -s[0];
for (int i = 1; i < n - 1; i++)... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | from itertools import accumulate
inf = 10**9 + 1
def solve():
n = int(input())
a = [int(i) for i in input().split()]
ad = [abs(a[i + 1] - a[i]) for i in range(n - 1)]
ap = [0] + list(accumulate(ai*(-1)**i for i, ai in enumerate(ad)))
max_dif, min_dif = max_min_profit(ap)
ans = max(max_dif, -m... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const int N = 100010;
map<long long, int> mp;
int main() {
long long n, i;
long long a[100010], b[100010];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lld", &a[i]);
if (i >= 1) b[i] = abs(a[i] - a[i - 1]);
}
long long ans = 0;
long long maxx = b... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
_l = list(map(int, input().split()))
l = [abs(_l[i] - _l[i + 1]) for i in range(n - 1)]
p, n, res = 0, 0, 0
for e in l:
_p = max(0, n + e)
_n = max(0, p - e)
p, n = _p, _n
res = max(p, n, res)
print(res) |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long const N = 1e6 + 5;
long long dp[N][2], a[N];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
long long n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
n--;
for (int i = 0; i < n; i++) a[i] = abs(a[i] - a[i + 1]);
long long mx = a... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX_N = 1e5 + 10;
const long long mod = 1e9 + 9;
const double PI = acos(-1);
int num[MAX_N];
long long dp[MAX_N];
int ab(int x) { return x > 0 ? x : -x; }
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long fastPow(long long a, long long b) {
long long ret = 1;
while (b) {
if (b & 1) ret *= a;
a *= a;
b >>= 1;
}
return ret;
}
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
long long n, e, o, ce, co, ret = INT_MIN, c;
cin >... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long> arr(n);
for (int i = 0; i < n; i++) cin >> arr[i];
for (int i = 0; i < n - 1; i++) {
arr[i] = abs(arr[i] - arr[i + 1]);
}
vector<long long> a(n), b(n);
a[0] = arr[0];
long long ans1 = a[0], ans2 = 0;
fo... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, INF = 0x7F;
long long n, a[maxn], f[maxn], sum[maxn], Max = -INF, Min = INF;
int main() {
scanf("%lld", &n);
for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
Max = max(Max, 0ll);
Min = min(Min, 0ll);
for (int i = 1; i < n; i++) {
f[... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(raw_input())
arr = map(int,raw_input().split())
arr1 = []
arr2 = []
for i in range(n-1):
if i%2 == 0:
arr1.append(abs(arr[i]-arr[i+1]))
arr2.append(-abs(arr[i]-arr[i+1]))
else:
arr1.append(-abs(arr[i]-arr[i+1]))
arr2.append(abs(arr[i]-arr[i+1]))
max1 = arr1[0]
curMax = arr1[0]
for i in range(1,n-... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
l = tuple(map(int, input().split()))
a = []
for i in range(n - 1):
a.append(abs(l[i] - l[i + 1]))
ev = [(a[i] if i % 2 == 0 else -a[i]) for i in range(n - 1)]
od = [-i for i in ev]
od[0] = 0
dp = [ev[0]]
st = ["ev"]
# print(a)
# print(ev)
# print(od)
vmax = dp[0]
evsum = evans = 0
odsum = oda... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.*;
import java.util.*;
public class C
{
static StringBuilder st = new StringBuilder();
static int n ;
static long [][] memo ;
static int [] a ;
static long dp(int idx , int neg)
{
if(idx == n - 1) return 0 ;
if(memo[neg][idx] != -1)return memo[neg][idx] ;
long diff = (neg ==... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... |
import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class tennis {
static boolean DEBUG_FLAG = false;
int INF = (int)1e9;
long MOD = 1000000007;
long p = 101;
long ans = 0;
static void debug(String s) {
if(DEBUG_FLAG) {
System.out.print(s);
}
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
static FastReader in;
static PrintWriter o;
public static void solve() {... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long int a[1000005];
long long int dp[1000005][2];
int main() {
long long int n;
scanf("%lld", &n);
for (long long int i = 1; i <= (long long int)n; i++) scanf("%lld", a + i);
dp[1][0] = abs(a[1] - a[1 + 1]);
dp[1][1] = -abs(a[1] - a[1 + 1]);
long long int ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const long long INF = 200000000000000000LL;
long long kadane(vector<long long> v) {
long long sum = 0;
long long ans = sum;
for (long long i : v) {
sum = max(sum + i, i);
ans = max(ans, sum);
}
return ans;
}
int main() {
int n;
scanf("%d", &n);
vecto... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long flag(vector<long long> &);
int main() {
vector<long long> a, b;
long long n, x, y, sum = 0, s, q;
cin >> n;
for (int i = 1; i != n + 1; ++i) {
if (i == 1) {
cin >> x;
continue;
}
cin >> y;
q = y - x;
if (q < 0) q = -q;
i... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | /**
* Created by sachgoya on 2/24/2017.
*/
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* Created by sachin.goyal on 07/02/17.
*/
public class C {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = Syste... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int const oo = 1e9, bound = 1e6 + 1, mod = oo + 7;
long long const OO = 1e18;
int n;
int aa[bound];
long long dp[bound][3][2];
long long rec(int idx, int tk, int sg) {
long long &ret = dp[idx][tk][sg];
if (ret != -1) return ret;
if (idx == n - 1) return ret = 0;
if ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n=input()
lst=map(int,raw_input().split())
lst2=[]
lst3=[]
for i in range(0,n-1):
vr=abs(lst[i+1]-lst[i])*(pow(-1,i))
lst2.append(vr)
lst3.append(-1*vr)
# Python program to find maximum contiguous subarray
# Function to find the maximum contiguous subarray
from sys import maxint
def maxSubArraySum(a,size... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = input()
a = map(int,raw_input().split())
ans = 0
#even indexed
p = 0
x = 1
cursum = 0
while p < len(a)-1:
cursum += abs(a[p]-a[p+1]) * x
if cursum < 0:
cursum = 0
if p % 2 != 0:
p += 1
else:
p += 2
x = 1
else:
ans = max(ans,c... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | from itertools import accumulate
inf = 10**9 + 1
def solve():
n = int(input())
a = [int(i) for i in input().split()]
ad = [abs(a[i + 1] - a[i]) for i in range(n - 1)]
ap = [0] + list(accumulate(ai*(-1)**i for i, ai in enumerate(ad)))
am = [0] + list(accumulate(ai*(-1)**(i + 1) for i, ai in enumer... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.PriorityQueue;
public final class CF_407_Functions {
static void log(int[] X){
int L=X.length;
for (int i=0;i<L;i++){
logWln(X[i]+" ");
}
log("");
}
static voi... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long int cal(vector<int> f) {
long long int sum = 0;
long long int cur = 0;
for (int i = 0; i < f.size(); ++i) {
cur += f[i];
if (cur < 0) {
cur = 0;
}
if (cur > sum) {
sum = cur;
}
}
return sum;
}
int main() {
ios_base::sync... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import math
def findmax(a):
c = ret = a[0]
for i in range(1, len(a)):
c = max(a[i], c + a[i])
ret = max(ret, c)
return ret
n = int(raw_input())
a = map(int, raw_input().split())
p = []
np = []
m = 1
for i in range(len(a) - 1):
p.append(abs(a[i] - a[i + 1]) * m)
m *= -1
if i > 0:... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Abood2C {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
Prin... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Codeforces {
public static void main(String[] args) {
InputStream inputStream = S... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 5;
long long v[MAXN];
long long a[MAXN];
long long dp[MAXN][2];
int m;
inline int sign(int x) {
if (x == 0) {
return 1;
}
return -1;
}
long long solve(int pos, int flag) {
if (pos >= m) {
return 0;
}
if (dp[pos][flag] != -1) {... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long int n, ans, s = 0, f = 0, arr[100005] = {0}, arr2[100005] = {0},
mx = -10000000000000000;
void kadane() {
for (int i = 0; i < n - 1; i++) {
if (arr2[i] + s < 0) {
s = 0;
} else {
s += arr2[i];
}
if (s > mx) {
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner x = new Scanner(System.in);
int n=x.nextInt();
long arr[] = new long [n];
for(int i=0;i<n;i++){
arr[i]=x.nextLong();
}
long[] sum = new long[n-1];
for(int i=0;i<n-1;i++)
{
sum[i]= Math.abs(arr[i... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | // package codeforces.cf4xx.cf407.div1;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class A {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
Print... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, N[100005];
long long int A[100005];
long long int B[100005];
cin >> n;
long long int i;
for (i = 1; i <= n; i++) {
cin >> N[i];
}
for (i = 1; i < n; i++) {
long long int k;
k = abs(N[i + 1] - N[i]);
if (i % 2 == ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(raw_input())
arr = map(int,raw_input().split())
newarr1 = []
newarr2 = []
one = 1
for i in xrange(n-1):
newarr1.append(one*abs(arr[i+1]-arr[i]))
newarr2.append(-1*one*abs(arr[i+1]-arr[i]))
one*=-1
val = 0
temp = []
for i in xrange(len(newarr1)):
if(val+newarr1[i]>0):
val += newarr1[i]
temp.append(val... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | def main():
n = int(input())
arr = list(map(int,input().split()))
dp = []
ans = -float('inf')
total = 0
for i in range(n-1):
if i%2 == 0:
total += abs(arr[i]-arr[i+1])
else:
total -= abs(arr[i]-arr[i+1])
ans = max(ans,abs(arr[i]-arr[i+1]))
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int main() {
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int ar[n];
for (int i = 0; i < n; i++) {
cin >> ar[i];
}
int b[n];
for (int i = 0; i < n - 1; i++) {
b[i] = abs(ar[i] - ar[i + 1]);
if (i... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.util.*;
public class Functional {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long[] arr = new long[n-1];
long last = in.nextLong();
for (int i = 1; i < n; i++) {
long current = in.nextLong();
arr[i-1] = Math.abs(last - current);
las... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def msi(): return map(str,input().split())
def li(): return list(mi())
n=ii()
a=li()
dp=[[0,0] for i in range(n)]
for i in range(1,n):
curr=abs(a[i]-a[i-1])
if dp[i-1][0]>0:
dp[i][1]=curr
dp[i][0]=... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<long long int> arr, arr2, x, y;
int n;
long long int temp;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%I64d", &temp);
arr.push_back(temp);
}
for (int i = 0; i < n - 1; i++) {
arr2.push_back(abs(arr[i] - arr[i + 1]));
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
d = []
for i in range(n-1):
if i%2==0:
d.append(abs(a[i+1]-a[i]))
else:
d.append(-abs(a[i+1]-a[i]))
ans = -10**18
m = 0
acc = 0
for i in range(n-1):
acc += d[i]
ans = max(ans, acc-m)
i... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | read = lambda: map(int, input().split())
n = int(input())
a = list(read())
d = [0] * n
b = [0] * n
c = [0] * n
sgn = 1
for i in range(1, n):
d[i] = abs(a[i - 1] - a[i])
b[i] = d[i] * sgn
c[i] = -b[i]
sgn *= -1
s = [0] * n
for i in range(1, n):
s[i] = s[i - 1] + b[i]
mn = ans = 0
for i in range(1, n)... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
using namespace std;
void print_width(long long x) {
std::cout << std::fixed;
std::cout << std::setprecision(x);
}
long long power(long long x, long long y, long long p = 1000000007) {
long long res = 1;
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.*;
import java.util.StringTokenizer;
import static java.lang.Math.max;
/**
* 788A
* θ(n) time
* θ(n) space
*
* @author artyom
*/
public class _788A implements Runnable {
private BufferedReader in;
private StringTokenizer tok;
private long solve() throws IOException {
int n = ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
i... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
a = list(map(int,input().strip().split()))
b = [0]*(n-1)
c = [0]*(n-1)
for i in range(n-1):
if (i)%2 == 0:
b[i] = (abs(a[i] - a[i+1]))
else:
b[i] = (abs(a[i] - a[i+1]))*(-1)
for i in range(1,n-1):
if (i-1)%2 == 0:
c[i] = (abs(a[i] - a[i+1]))
else:
c[i] ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int n;
long long dat[100002];
long long dif[100002];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> dat[i];
dif[i] = dat[i] - dat[i - 1];
if (dif[i] < 0) dif[i] *= -1;
}
long long may = INT_MIN;
long long aux = 0;
long long par = 0;
l... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
long long num[maxn];
long long sum[maxn];
long long getmaxsum(long long *s, int n) {
long long Max = 0;
long long ssum = 0;
for (int i = 0; i < n; ++i) {
ssum += s[i];
Max = max(ssum, Max);
if (ssum < 0) ssum = 0;
}
return Max... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1):
b.append(abs(a[i] - a[i + 1]))
mx = -float('inf')
now = 0
for i in range(n - 1):
now += b[i] * (-1) ** (i % 2)
mx = max(mx, now)
if now < 0:
now = 0
now = 0
for i in range(1, n - 1):
now += b[i] * (-1) ** (i %... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long int maxSubArraySum(vector<long long int> a, int size) {
long long int max_so_far = 0, max_ending_here = 0, pos = 1;
for (int i = 0; i < size; i++) {
if ((max_ending_here + a[i]) < a[i]) {
max_ending_here = a[i];
pos = 1;
} else
max_en... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.PrintWriter;
public class C_407 {
public static int mod = 1000000007;
static FastReader scan = new FastReader();
static PrintWriter out = new PrintWriter(System.out);
public static void main(String args[]... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
a = list(map(int, input().split()))
b = []
f = 1
for i in range(len(a) - 1):
b.append(abs(a[i] - a[i + 1]) * f)
f *= -1
max1, max2 = 0, 0
a1, a2 = 0, 0
for i in range(n - 1):
if a1 + b[i] > 0:
a1 += b[i]
else:
a1 = 0
max1 = max(a1, max1)
if a2 - b[i] > 0:
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
using pii = pair<long long, long long>;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n;
cin >> n;
vector<long long> a(n);
for (long long i = 0; i < n; i++) cin >> a[i];
vector<long long> b(n);
for ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | def f(l, r, p):
if l > r: return 0
return p[r] - p[l - 1] if l % 2 == 1 else -f(l - 1, r, p) + p[l - 1]
def main():
read = lambda: tuple(map(int, input().split()))
n = read()[0]
v = read()
p = [0]
pv = 0
for i in range(n - 1):
cp = abs(v[i] - v[i + 1]) * (-1) ** i
pv +=... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner in=new ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
const long long INF = numeric_limits<long long>::max();
enum { EVEN, ODD };
int A[MAXN];
long long dp[2][MAXN];
int main() {
int N;
cin >> N;
for (int i = 1; i <= N; ++i) cin >> A[i];
dp[ODD][1] = dp[EVEN][1] = dp[ODD][2] = -INF;
dp[E... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long int p1(int i) {
if (i % 2 == 0)
return 1;
else
return -1;
}
int main() {
long long int n;
cin >> n;
vector<long long int> a(n + 1, 0), psum(n + 1, -10000000000);
for (int i = 1; i < n + 1; i++) scanf("%lld", &a[i]);
psum[2] = abs(a[1] - a[2])... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #!/usr/bin/python
# coding: utf-8
n=int(raw_input())
arr=map(long,raw_input().split(' '))
arr1=[]
for i in xrange(n-1):
tmp=abs(arr[i+1]-arr[i])
tmp=tmp*((-1)**i)
arr1.append(tmp)
arr2=[]
for i in xrange(n-1):
arr2.append(arr1[i]*(-1))
max=current=0
for i in xrange(n-1):
current+=arr1[i]
if(c... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int a[maxn];
long long b[maxn], sum[maxn];
long long getMax(int n) {
sum[0] = 0;
for (int i = 0; i < n; i++) {
sum[i + 1] = sum[i] + b[i];
}
long long res = 0;
int id = 0;
for (int i = 1; i <= n; i++) {
if (sum[i] - sum[id] <= 0)... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long a[100005];
long long dp[100005][2];
int main() {
long long res, n, k;
while (cin >> n) {
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n - 1; i++) {
a[i] = abs(a[i] - a[i + 1]);
}
long long ans = 0;
for (i... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1000000;
const double pi = 3.1415926535897932384626433832795;
using namespace std;
long long ans = -MAXINT, n;
long long x1[300000];
long long x2[300000];
void check(long long xx) {
long long ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
long long kadane(const vector<long long> &v) {
long long ans = 0;
long long curr = 0;
for (long long n : v) {
curr += n;
ans = max(ans, curr);
if (curr < 0) curr = 0;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
int n;
scanf("%d... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.util.*;
import java.io.*;
public class C1{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(input())
a = [*map(int, input().split())]
a = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
ans = t1 = t2 = 0
for i in a:
t1, t2 = max(t2 + i, 0), max(t1 - i, 0)
ans = max(ans, t1, t2)
print(ans) |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import math
def getMax(a, n):
MAX = -1*pow(10, 9)
memoize = [[0 for x in range(2)] for y in range(n)]
difference = [0 for x in range(n)]
for i in range(n):
if i > 0:
difference[i] = abs(a[i]-a[i-1])
for i in range(1, n):
memoize[i][0] = max(difference[i], memoize[i-1][1] ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
public class Main{
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Main2 {
public static void main(String[] args) {
FastScanner scanner = new FastScanner();
int n = scanne... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(raw_input())
ll = list(map(int, raw_input().split()))
l = [abs(ll[i] - ll[i + 1]) for i in xrange(n - 1)]
d = [[0, 0] for i in xrange(n - 1)]
d[n - 2] = [l[n - 2], l[n - 2]]
ans = d[n - 2][1]
for i in xrange(n - 3, -1, -1):
d[i][0] = l[i] - max(0, d[i + 1][1])
d[i][1] = l[i] - min(0, d[i + 1][0])
if... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | # In this template you are not required to write code in main
import sys
inf = float("inf")
sys.setrecursionlimit(1000000)
#from cmath import sqrt
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,flo... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n=int(input())
*a,=map(int,input().split())
l=[abs(a[i]-a[i-1]) for i in range(1,n)]
ans=0
x=y=0
for i in range(n-1):
t=[l[i],-l[i]][i%2]
x+=t
y-=t
ans=max(ans,x,y)
x=max(x,0)
y=max(y,0)
print(ans) |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | #include <bits/stdc++.h>
using namespace std;
int n;
long long a[110000];
long long b[110000];
long long dp[110000][2];
long long myabs(long long x) {
if (x < 0)
return -x;
else
return x;
}
int main() {
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
for (int i ... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | n = int(raw_input())
l = [int(x) for x in raw_input().split()]
l1 = []
l2 = []
def best(ll):
ans = ll[0]
sm = 0
min_sum = 0
for a in ll:
sm += a
ans = max(ans, sm - min_sum)
min_sum = min(min_sum, sm)
return ans
for i in xrange(n-1):
val = abs(l[i+1]-l[i])
if i % 2 == 0:
val = -val
l1.append(val)
... |
Problem: Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is d... | import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
public class Main {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int n = sc.nextInt();
long[] a = sc.nextLongList(n);
long[] b = new long[n];
b[0] = a[0];
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.