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> using namespace std; int main(int argc, const char* argv[]) { std::ios::sync_with_stdio(false); int n; cin >> n; vector<long long> data(n); for (int i = 0; i < n; ++i) { cin >> data[i]; } vector<long long> data2; for (int i = 0; i < n - 1; ++i) { data2.push_back(abs(data...
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.*; public class D { static BufferedReader in; static PrintWriter out; static StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args) throws 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 fb1; //package fb1; import java.util.*; import java.io.*; import java.lang.Math.*; public class MainA { public static int mod = 20000; public static long[] val; public static long[] arr; static long max = (long) 1e10 + 7; static long count=0; static int l=0; 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...
#include <bits/stdc++.h> using std::vector; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); size_t array_size; std::cin >> array_size; vector<int64_t> array(array_size); for (auto& elem : array) { std::cin >> elem; } vector<int64_t> diffs; for (size_t i = 1; i < array.si...
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 = 100010; int main() { int n; long long a[maxn]; long long dp[maxn], cp[maxn]; while (cin >> n) { for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) a[i] = abs(a[i + 1] - a[i]); long long ans = 0; for (int i = n - 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...
#include <bits/stdc++.h> using namespace std; long long dp[100005], a[100005]; int main() { ios::sync_with_stdio(false); int n; long long ans1 = 0, ans2 = 0, ans = 0, pre, now; cin >> n; cin >> pre; for (int i = 1; i < n; i++) { cin >> now; a[i] = abs(now - pre); pre = now; } for (int 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...
n = int(raw_input()) a = [int(x) for x in raw_input().split()] l = [] if n == 1: print 0 exit() if n == 2: print abs(a[0]-a[1]) exit() for i in range(len(a)-1): l.append(abs(a[i]-a[i+1])) ans = [-1]*len(l) ans[-1] = l[-1] ans[-2] = l[-2] for i in range(-3,-n,-1): ans[i] = max(l[i],l[i]+ans[i+2]-l[i+1]) print 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...
import java.io.*; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; import java.lang.*; import java.math.*; import java.text.DecimalFormat; import java.lang.reflect.Array; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; ...
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 b[100000], m = 0; int n; void dp() { long long sum = 0; for (int i = 0; i < n; i++) { sum += b[i]; if (sum < 0) sum = 0; m = max(m, sum); } } int main() { cin >> n; long long num, last; cin >> last; n--; for (int i = 0; i < n; 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.*; import java.io.*; public class A { public static void main(String[] args) throws IOException { FastScanner qwe = new FastScanner(System.in); int n = qwe.nextInt(); int[] a = new int[n]; for (int i = 0; i < a.length; i++) { a[i] = qwe.nextInt(); } long best = 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...
if __name__ == "__main__": n = input() a = map(int, raw_input().split()) f = [0] * (n - 1) for i in range(n - 1): f[i] = abs(a[i] - a[i + 1]) res = max(f) tmp = 0 for i in range(n - 1): fi = f[i] if (i % 2 != 0): fi = -fi tmp += fi if tm...
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 = 100004; long long a[N], b[N]; int n, p = 0; long long fun(int n) { long long ans = 0, sum = 0; for (int i = 1; i <= n; i++) { sum += b[i]; if (sum < 0) sum = 0; ans = max(ans, sum); } return ans; } int main() { long long ans = 0; scanf(...
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())] s = [abs(a[i] - a[i + 1]) for i in range(n - 1)] x = y = ans = 0 for i in s: x1 = max(y + i, 0) y1 = max(x - i, 0) x, y, ans = x1, y1, max(x1, y1, ans) 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; void solve() { int n; cin >> n; vector<long long> a(n); for (auto &it : a) cin >> it; ; long long dp[n + 5][5]; memset(dp, 0, sizeof(dp)); dp[0][1] = abs(a[0] - a[1]); long long ans = dp[0][1]; for (int i = 1; i < n - 1; i++) { dp[i][1] = max(dp[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...
lectura= lambda:map (int, input().split()) n= (list(lectura())[0]) lista= list(lectura()) fDescrita=0 alt1=1 maxV1=0 maxV2=0 C1=0 C2=0 for i in range(0, n -1): fDescrita= abs(lista[i] - lista[i + 1]) * alt1 maxV1=max(maxV1 + fDescrita, fDescrita) maxV2 = max(maxV2, maxV1) alt1 = alt1 * (-1) #print(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...
import math n=int(input()) a=list(map(int,input().split())) b=[] dp1=[] dp2=[] c=[] d=[] for i in range(n-1): b.append(abs((a[i+1]-a[i]))) for j in range(n-1): if(j%2): c.append(b[j]) d.append(-1*b[j]) else: c.append(-1*b[j]) d.append(b[j]) dp1.append(c[0]) dp2.append(d[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.*; import java.util.*; public class Main2 { public static void main(String[] args) throws IOException { new Main2().solve(); } int inf = 2000000000; int mod = 1000000007; double eps = 0.0000000001; PrintWriter out; int n; int m; //ArrayList<Integer>[] g ...
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 Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); List<Integer> a=new ArrayList<Integer>(); for(int i=0;i<n;i++){ a.add(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...
#include <bits/stdc++.h> using namespace std; int T; int N; int A[100101], B[100101]; 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] = abs(A[i] - A[i + 1]); if (i % 2 == 0) B[i] = -B[i]; } long long mn = 1000000000000000000, mx = -1000...
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(false); cin.tie(0); cout.precision(10); cout << fixed; srand(time(0)); int n; cin >> n; vector<long long> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } vector<long long> a, b; int c = 1; for (int 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.util.Scanner; public class MaxFn { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); } sc.close(); long lmax=Math.abs(a[0]-a[1]); int sign=-1; long rmax=sign*lmax; 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...
def maxSubArraySum(a,size): max_so_far =a[0] curr_max = a[0] for i in range(1,size): curr_max = max(a[i], curr_max + a[i]) max_so_far = max(max_so_far,curr_max) return max_so_far # def get() n = int(input()) a = list(map(int,input().split())) aa = [abs(a[i]-a[i+1]) for i in range(n-1)] b = [aa[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; const int N = 100002; int n; long long dp[N], a[N], diffs[N]; int main() { scanf("%d", &n); for (int i = (1); i <= (int)(n); ++i) scanf("%lld", &a[i]); for (int i = (1); i <= (int)(n - 1); ++i) diffs[i] = abs(a[i] - a[i + 1]); dp[1] = diffs[1], dp[2] = diffs[2]; 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...
import java.io.*; import java.math.*; import java.util.*; // @author : Dinosparton public class test { static class Pair{ long x; long y; Pair(long x,long y){ this.x = x; this.y = y; } } static class Compare { void compare(Pair arr[],...
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 math import fabs n = int(input()) a = list(map(int,input().split(" "))) a.insert(0,0) n += 1; dpmin = [0]*n dpmax = [0]*n dpmin[2] = abs(a[2]-a[1]) dpmax[2] = abs(a[2]-a[1]) for i in range(3,n) : dpmax[i] = max(abs(a[i]-a[i-1]) ,abs(a[i]-a[i-1])-dpmin[i-1] ) dpmin[i] = min(abs(a[i]-a[i-1]) ,abs(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; int64_t f(vector<int64_t> v) { int64_t best = 0; int64_t curr = 0; for (int i = 0; i < v.size(); i++) { curr += v[i]; best = max(best, curr); if (curr < 0) curr = 0; } return best; } int main() { int n; cin >> n; vector<int64_t> v(n); 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> using namespace std; int main() { int n; cin >> n; long long int a[n + 5]; for (int i = 0; i < (n); i++) cin >> a[i]; long long int x[n + 5], y[n + 5]; for (int i = 0; i < (n - 1); i++) { long long int z = abs(a[i] - a[i + 1]); if (i % 2 == 0) { x[i] = z; y[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.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class FunctionsAgain { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 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.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparato...
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 maxsubsum(vector<int> &vec) { long long maxsum = 0; long long cursum = 0; for (int i = 0; i < vec.size(); i++) { cursum += vec[i]; if (cursum < 0) cursum = 0; maxsum = max(maxsum, cursum); } return maxsum; } int main() { int n; cin >> 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; const int N = 100010; long long dp[2][N], a[N], f[N]; int main() { int n; cin >> n; for (int i = 0; i < (int)n; i++) cin >> a[i]; f[0] = abs(a[0] - a[1]); for (int i = 1; i < (int)n - 1; i++) { f[i] = abs(a[i] - a[i + 1]); } dp[0][0] = f[0]; dp[1][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[100100], b[100100], c[100100], d[100100]; int main() { long long n, i, t; scanf("%I64d", &n); for (i = 0; i < n; i++) scanf("%I64d", &a[i]); for (i = 0; i < n - 1; i++) b[i] = abs(a[i] - a[i + 1]); c[n] = 0; d[n] = 0; long long ans = LLONG_MIN; 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...
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.InputMismatchException; import java.util.*; import java.io.*; im...
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> data(n + 1); for (int i = 1; i <= n; i++) { scanf("%lld", &data[i]); } vector<long long> b(n + 1); vector<long long> c(n + 1); vector<long long> pref1(n + 1); vector<long long> pref2(n + 1); 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...
#include <bits/stdc++.h> using namespace std; vector<long long int> v1, v2, v; long long int res = -1000000000000000000; int n; int main() { cin >> n; for (int i = 0; i < n; i++) { long long int x; cin >> x; v.push_back(x); } for (unsigned long long int i = 0; i < v.size() - 1; i++) { 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; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n = 0, ans = 0; cin >> n; vector<long long> a(n), f1(n), f2(n); for (long long i = 0; i < n; i++) { cin >> a[i]; if (i) { f1[i] = abs(a[i] - a[i - 1]) * pow(-1, 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 java.util.*; import java.io.*; public final class CF { static long ans(long[] a) { long max = Integer.MIN_VALUE; long curr = 0; for(int i = 0; i<a.length; i++) { curr+=a[i]; if(max<curr) max = curr; if(curr<0) curr = ...
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 N, A[100005]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> N; for (int i = int(1); i < int(N + 1); i++) cin >> A[i]; long long best = 0, acc = 0; for (int i = int(1); i < int(N); i++) { acc += abs(A[i] - A[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 binpow(long long a, long long b, long long m) { a %= m; long long res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } struct Sieve { long long n; vector<long long> primes, f; Sieve(long long nn...
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 cf407c { static final int N=(int)1e5+10; static final long inf=(long)1e10; static int a[]=new int[N]; static int b[]=new int[N]; static int c[]=new int[N]; public static void main(String[] args){ Scanner cin=new Scanner(new Inpu...
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_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long N; cin >> N; long long v[N]; for (long long i = 0; i < N; i++) cin >> v[i]; long long arr1[N - 1], arr2[N - 1]; for (long long i = 0; i < N - 1; i++) { arr1[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 main() { int i = 0, j = 0, cs = 0, in; int n; cin >> n; vector<int> v, a, b; for (i = 0; i < n; i++) { cin >> in; v.push_back(in); }; for (i = 0; i < n - 1; i++) { int x = abs(v[i + 1] - v[i]); if (i & 1) a.push_back(-1 * x), b.push_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; const int N = int(1e5) + 5; int n; int a[N]; long long dp[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 1; i <= n; cin >> a[i++]) ; for (int i = 1; i <= n - 1; i++) a[i] = abs(a[i] - a[i + 1]); dp[1] = (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...
import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; public class Main { public static class FastReader { BufferedReader br; StringTokenizer root; 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...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> arr(n + 1, 0); for (long long i = 1; i <= n; i++) cin >> arr[i]; vector<long long> val(n + 1, 0); for (long long i = 1; i < n; i++) { if (i % 2 == 0) val[i] = abs(arr[i] - arr[i + 1]) * -1; else...
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.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; import java.io.*; public class codeforces { static class Student{ int e,l; Student(int e,int 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; long long mod = 1000000007; inline long long mpow(long long b, long long ex) { if (b == 1) return 1; long long r = 1; while (ex) { if (ex & 1) r = (r * b) % mod; ex = ex >> 1; b = (b * b) % mod; } return r; } long long n, m, k; long long b1, q, l; 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...
import java.util.Scanner; import java.util.Arrays; public class Main{ static final long INF = Long.MAX_VALUE / 2; static int n; static int[] a; public static void main(String[] args){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); a = new int[n]; for(int i = 0; i < n; i++){ a[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 io, os # input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline import sys # sys.stdin=open('input.txt','r') # sys.stdout=open('output.txt','w') input=sys.stdin.readline # sys.setrecursionlimit(300010) MOD = 1000000007 MOD2 = 998244353 ii = lambda: int(input().strip('\n')) si = lambda: input().strip('\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...
#!/usr/bin/python # coding: utf-8 n=int(raw_input()) arr=map(long,raw_input().split(' ')) arr1=[] arr2=[] for i in xrange(n-1): tmp=abs(arr[i+1]-arr[i]) tmp1=tmp*((-1)**i) arr1.append(tmp1) tmp2=tmp*((-1)**(i+1)) arr2.append(tmp2) max1=max2=current1=current2=0 for i in xrange(n-1): current1+...
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 mm = 1000000007; long long powe(long long a, long long n) { long long ans = 1; while (n) { if (n & 1) ans = (ans * a) % mm; n = n / 2; a = (a * a) % mm; } return ans; } long long fac[100005]; void precum() { fac[0] = 1; for (long long 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...
from sys import stdin rints = lambda: [int(x) for x in stdin.readline().split()] n, a, ans, tem1, tem2 = int(input()), rints(), 0, 0, 0 diff = [abs(a[i] - a[i - 1]) for i in range(1, n)] for i in range(n - 1): if i % 2 == 0: tem1 += diff[i] tem2 -= diff[i] if tem2 < 0: tem2 = 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.util.Scanner; public class Test { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n=scan.nextInt(); long max=0, up=scan.nextLong(), abs=0, max2=0, temp=0, dif=0; for (int i=0; i<n-1; i++) { long down = scan.nextLong(); abs = Math.abs(up - 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.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.StringTokenizer; public class Div2407C { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream 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.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class R407Div2C { public static void main(String[] args) { FastScanner in=new FastScanner(); int n=in.nextInt(); int[] a=new int[n-1]; int b=in.nextInt(),c=0; for(int i=0;i<n-1;i++){ c=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...
#include <bits/stdc++.h> using namespace std; long long int maxsum(vector<long long int> a) { long long int max_so_far = -1000000000000, max_ending_here = 0; for (int i = 0; i < a.size(); i++) { max_ending_here = max_ending_here + a[i]; if (max_so_far < max_ending_here) max_so_far = max_ending_here; 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...
#include <bits/stdc++.h> using namespace std; const long long lnf = (1LL << 61); int n; int* a; long long sodd = 0, suodd = 0; long long great[2][2] = {{lnf, -lnf}, {lnf, -lnf}}; long long res = -0x3fffffff; inline void init() { scanf("%d", &n); a = new int[(const int)(n + 1)]; for (int i = 1; i <= n; i++) scanf(...
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> a(n); for (int i = 0; i < n; i++) { long x; cin >> x; a[i] = x; } long long b[n], c[n]; for (int i = 0; i < n - 1; i++) { b[i] = abs(a[i] - a[i + 1]); c[i] = b[i]; if (i % 2 == 0) { 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.util.*; import java.math.*; import java.io.*; import java.text.*; public class A{ static class Node{ int x; long cost; public Node(int x,long cost) { this.x=x; this.cost=cost; } } //public static PrintWriter pw; public static PrintWriter pw=new PrintWriter(System.out); 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 f[100005]; long long input[100005]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &input[i]); } for (int i = 1; i < n; i++) { f[i - 1] = input[i - 1] - input[i]; f[i - 1] = labs(f[i - 1]); } long long last...
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.util.*; public class CTask { public static void main(String[] args) throws IOException { MyInputReader in = new MyInputReader(System.in); int n = 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...
n=input() nums=map(int,raw_input().split());dp=[0]*(n-1);dp2=[0]*(n-1) for i in xrange(n-1): dp[i]=abs(nums[i]-nums[i+1])*(-1)**i dp2[i]=-dp[i] best=0;tot=0;best2=0;tot2=0 for i in xrange(n-1): tot=max(dp[i],tot+dp[i]);tot2=max(dp2[i],tot2+dp2[i]) best=max(best,tot);best2=max(best2,tot2) print max(best,...
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() { int n; cin >> n; vector<long long> a(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]); vector<pair<long long, long long>> dp(n); long long ans = a[0]; dp[0] = {a[0], -1e17}; 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...
import java.io.*; import java.util.*; import java.math.BigInteger; import java.util.Map.Entry; import static java.lang.Math.*; public class A extends PrintWriter { void run() { int n = nextInt(), m = n - 1; int[] a = nextArray(n); long[] s = new long[n]; for (int i = 1, sign = 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; int64_t calc(vector<int64_t> &v) { int64_t tec = 0, mx = 0; for (int64_t i = 0; i < v.size(); ++i) { if (tec < 0) tec = 0; tec += v[i]; if (tec > mx) mx = tec; } return mx; } int32_t main() { ios_base::sync_with_stdio(false); int64_t n; cin >> 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; const int maxn = 1e5 + 4; long long int a[maxn], dif1[maxn], dif2[maxn]; long long int kadane(long long int arr[], int n) { long long int ans = -2e9, curr_max = -2e9; for (int i = 1; i < n; i++) { curr_max = max(arr[i], curr_max + arr[i]); ans = max(curr_max, an...
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 sys import stdin from itertools import repeat def main(): n = int(stdin.readline()) a = map(int, stdin.readline().split(), repeat(10, n)) b = map(abs, [a[i+1] - a[i] for i in xrange(n - 1)]) ans = max(b) b[1::2] = [-x for x in b[1::2]] c = t = 0 for x in b: c += x if t >...
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())) d1 = [] d2 = [] for i in range(n - 1): if i % 2 == 0: d1.append(abs(a[i] - a[i + 1])) d2.append(-1 * abs(a[i] - a[i + 1])) else: d1.append(-1 * abs(a[i] - a[i + 1])) d2.append(abs(a[i] - a[i + 1])) s1 = [0 for i in range(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; const int N = 2e3 + 5; const int nmax = 1e5 + 5; const int mod = 1e9 + 7; const long double eps = 1e-18; const long double PI = acos(-1.0); const long long inf = 1e9; const long double big = 1e18; long long d[nmax]; long long s[nmax]; long long a[nmax]; long long ABS(long 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...
import java.util.*; public class FunctionsAgain{ public static void main(String[] args) { Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int a[] = new int [n-1]; int ultimo = sc.nextInt(); for (int i=1;i<n;i++) { int actual = sc.nextInt(); a[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...
n=int(input()) w=[int(k) for k in input().split()] a=[] for j in range(1, len(w)): a.append(abs(w[j]-w[j-1])) b, c=[], [] for j in range(len(a)): if j%2: b.append(-a[j]) c.append(a[j]) else: b.append(a[j]) c.append(-a[j]) res=0 x, y=[], [] q=0 for j in b: x.append(q) ...
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.*; import java.lang.Math; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class GFG { static class FastReader{ BufferedReader br; StringTokenizer st;...
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, a[100005], b[100005], dp[100005]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (long long int i = 1; i <= n; ++i) cin >> a[i]; for (long long int i = 1; i <= n - 1; ++i) b[i] = abs(a[i] - a[i + 1]); n--; 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 math import sys n = int(input()) a = [] b = [None] * n c = [None] * n for x in input().split(): a.append(int(x)) for i in range(0, n - 1): b[i] = c[i] = abs(a[i + 1] - a[i]) b[i] *= math.pow(-1, i) c[i] *= math.pow(-1, i + 1) maxCurrB = b[0] maxB = b[0] maxCurrC = c[0] maxC = c[0] for i in ra...
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...
R = lambda : map(int, input().split()) n = int(input()) a = list(R()) for i in range(len(a) - 1): a[i] = abs(a[i] - a[i + 1]) a = [v * (1 if i % 2 == 0 else -1) for i, v in enumerate(a[:-1])] res = 0 running_sum = 0 for i in range(len(a)): running_sum += a[i] res = max(res, abs(running_sum)) if running_...
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 __print(int x) { cout << x; } void __print(long x) { cout << x; } void __print(long long x) { cout << x; } void __print(unsigned x) { cout << x; } void __print(unsigned long x) { cout << x; } void __print(unsigned long long x) { cout << x; } void __print(float x) { cou...
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.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class A407 { public static void main(String[] args) { FS scan = new FS(System.in); int N = scan.nextInt(); long[] list = new long[N]; for(int 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 int N = 100000; int a[N]; void solve() { int n; 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]); } n--; long long sm = a[0]; long long mx = sm; for (int i = 1; i < n; 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.Scanner; public class FunctionsAgain { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] arr = new int[100002]; for(int i = 1 ; i < n+1 ; i++) arr[i] = scan.nextInt(); int[] 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...
#include <bits/stdc++.h> using namespace std; int dat[100005]; long long s[100005]; int main() { int n; scanf("%d", &n); long long ans = LLONG_MIN; for (int i = 1; i <= n; i++) { scanf("%d", &dat[i]); s[i] = abs(dat[i] - dat[i - 1]); } s[1] = 0; long long now = 0; for (int i = 2; i <= n; 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...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> v(n), b(n - 1), c(n - 2); for (int i = 0; i < n; i++) cin >> v[i]; b[0] = abs(v[1] - v[0]); if (n == 2) { cout << b[0]; return 0; } for (int i = 2; i < n; i++) { if (i % 2) b[i - 1] = abs(v[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...
/**************************************************\ | | |-----------| |-----------|| | | | | | | | | | | |------------| |------| | | | | | | | | | |...
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 functionAgain { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); long n=sc.nextLong(); long a=sc.nextLong(); long sum=0,max=0,min=0; for(int i=1;i<n;i++) { long b=sc.nextLong(); 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> using namespace std; long long a[1000001]; int main() { long long n, k; cin >> n >> k; long long count = 0; for (long long i = 0; i < n - 1; i++) { long long x; cin >> x; count += (pow(-1, i) * (abs(k - x))); a[i] = count; k = x; } sort(a, a + n - 1); if (a[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...
from sys import stdin, stdout n = int(stdin.readline()) values = list(map(int, stdin.readline().split())) first = [] second = [] ans = float('-inf') for i in range(n - 1): first.append(abs(values[i] - values[i + 1]) * (-1) ** i) second.append(abs(values[i] - values[i + 1]) * (-1) ** (i + 1)) cnt = 0 for i 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...
R=lambda:list(map(int,input().split())) n=int(input()) a=R() dif=[0]*(n-1) for i in range(n-1): dif[i]=abs(a[i]-a[i+1])*(1-2*(i%2)) sum=[0]*(n) sum[0]=0 for i in range(1,n): sum[i]=sum[i-1]+dif[i-1] ma=[0]*(n-1) mi=[0]*(n-1) for i in range(n-2,-1,-1): ma[i]=max(sum[i+1],ma[i+1] if i<n-2 else sum[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...
n = int(input()) a = [int(i) for i in input().split()] b = [abs(a[i] - a[i - 1]) for i in range(1, len(a))] sm = [[0] * 2 for i in range(n)] mn = [[0] * 2 for i in range(n + 1)] ans = -1000000 for i in range(n - 2, -1, -1): if i % 2 == 0: sm[i][0] = b[i] + sm[i + 1][0] sm[i][1] = -b[i] + sm[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...
n = int(input()) l = list(map(int,input().split())) M = abs(l[0]-l[1]) k = 0 i = 0 t_p = 0 t_n = 0 while ( i < n-1 ) : k = ( abs(l[i]-l[i+1]),-abs(l[i]-l[i+1]) )[i%2] t_n += k t_p -= k M = max(M,t_n,t_p) t_p = max(0,t_p) t_n = max(0,t_n) i += 1 print(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 long long N = 1e5 + 7; const long long inf = 1e18 + 7; const long long mod = 1e9 + 7; int n; int a[N]; long long mn; long long mn1; long long sum; long long sum1; long long b[N]; long long c[N]; int main() { ios_base::sync_with_stdio(false); cin >> n; 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...
#include <bits/stdc++.h> using namespace std; long long a[200001]; long long b[200001]; int main() { int n, i, k, j; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n - 1; i++) { b[i] = abs(a[i + 1] - a[i]); } long long f = -1; long long ans1 = b[0], ans2 = b[1], ma1 = b[0], 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...
n = int(input()) a = list(map(int, input().split())) b = [] sign = 1 for i in range(len(a)-1): b.append( abs(a[i]-a[i+1]) * sign ) sign *= -1 max_ = 0 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; int main() { long long int n, curr, posFor, negFor, temp, *arr; long long int maxp, maxn; cin >> n; arr = new long long int[n]; for (long int i = 0; i < n; i++) { cin >> temp; arr[i] = temp; } maxp = maxn = LONG_MIN; negFor = 0; posFor = 0; 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...
""" Code of Ayush Tiwari Codeforces: servermonk Codechef: ayush572000 """ import sys input = sys.stdin.buffer.readline def solution(): n=int(input()) l=list(map(int,input().split())) d=[0]*(n+1) for i in range(n-1): if i%2==0: d[i+1]=d[i]+abs(l[i]-l[i+1]) else: ...
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 = 1e5 + 7; long long dp[2][N]; int main() { int T; int n; cin >> n; vector<long long> a(n + 1); for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); } long long res = 0; for (int i = 1; i < n; ++i) { long long tmp = abs(a[i + 1] - a[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 sys import os import time import collections from collections import Counter, deque import itertools import math import timeit import random from io import BytesIO, IOBase from bisect import bisect_left as bl from bisect import bisect_right as br ######################### # imgur.com/Pkt7iIf.png # #############...
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.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class FunctionsAgain { InputStream is; PrintWriter pw; String INPUT = ""; long L_INF = (1L << 60L); void solve() { int n = ni(), 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...
import java.io.*; import java.util.*; import java.math.BigInteger; import java.lang.Object; public class Main { static class sort implements Comparator<int[]> { public int compare(int[] a,int[] b) { if(a[1] == b[1]) return -b[0]+a[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...
n = int(input()) arr = list(map(int, input().strip().split())) arr1 = [(1-2*(i%2))*abs(arr[i]-arr[i+1]) for i in range(n-1)] arr2 = [(1-2*(1-i%2))*abs(arr[i]-arr[i+1]) for i in range(n-1)] so_far = 0 sumi = 0 # print(arr1) # print(arr2) for i in arr1: sumi += i if sumi < 0: sumi = 0 else: ...
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() { int n; cin >> n; vector<long long> a(n); for (auto &it : a) cin >> it; ; long long dp[n + 5][5]; memset(dp, 0, sizeof(dp)); dp[0][1] = abs(a[0] - a[1]); long long ans = dp[0][1]; for (int i = 1; i < n - 1; i++) { dp[i][1] = max(dp[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; const int N = 1e6 + 5; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long long arr[n]; for (int i = 0; i < n; ++i) { cin >> arr[i]; } vector<long long> a, b; for (int i = 0; i < n - 1; i++) { if (i % 2) { ...