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... | n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1):
b.append(abs(a[i] - a[i + 1]))
c = []
s = 1
summ = 0
for i in range(n - 1):
summ += s * b[i]
s = -s
c.append(summ)
c.sort()
if c[0] < 0:
print(c[n - 2] - c[0])
else:
print(c[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... | n=int(input())
a=list(map(int,input().split()))
b=[abs(a[i]-a[i+1]) for i in range(n-1)]
p,q,r=0,0,0
for i in b:
_p=max(0,q+i)
_q=max(0,p-i)
p,q=_p,_q
r=max(p,q,r)
print(r) |
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 find(vector<long long int> &x) {
int n = x.size(), i;
long long int mx_end = 0, mx_till = -1e15;
for (int i = 0; i < n; i++) {
mx_end = mx_end + x[i];
mx_till = max(mx_till, mx_end);
if (mx_end < 0) mx_end = 0;
}
return mx_till;
}
int 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... | import math as mt
import sys
import bisect
input=sys.stdin.readline
#t=int(input())
def takeSecond(elem):
return elem[1]
def gcd(a,b):
if (b == 0):
return a
return gcd(b, a%b)
def kadane(l):
#print(l)
maxim=sum(l[:])
curr=0
for i in range(len(l)):
curr+=l[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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Mayank
*/
public class Main {
public static void main(String[] args) {
InputStream 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.util.Scanner;
public class Main {
private static long[][] dp = new long[100010][2];
private static long[] input = new long[100010];
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
int i , j , n = scan.nextInt();
long ans = Long.MIN_VALUE;
... |
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 a[100005];
long long dp[100005][2];
const long long inf = 1e16;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
dp[1][0] = abs(a[1] - a[2]);
dp[1][1] = -inf;
long long l = dp[1][1], r = dp[1][0];
long long ans = dp[1][0];
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.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static int mod=(int)1e9+7;
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
int n=sc.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;
const int N = 100005;
const long long INF = 1LL << 60LL;
int n;
int a[N], candidate[N];
long long res = -(INF);
inline void solve(int st) {
long long curPrefix = 0;
long long minPrefix = 0;
for (int i = st; i < n; i++) {
curPrefix += candidate[i];
res = max(re... |
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()
l=[0]+map(int,raw_input().split())
l=[0]+[abs(l[i]-l[i+1]) for i in range(1,n)]
ans=l[1]
sm1,sm2=0,0
for i in range(1,n):
if i%2:
temp = -l[i]
else:
temp=l[i]
sm1+=temp
sm2-=temp
ans=max(ans,sm1,sm2)
sm1=max(sm1,0)
sm2=max(sm2,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... | import java.util.*;
public class Functions{
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
int n = sc.nextInt();
int a[] = new int [n-1];
int ult = sc.nextInt();
for (int i=1;i<n;i++) {
int actual = sc.nextInt();
a[i-1] = Math... |
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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) throws IOException {
Sca... |
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 static java.lang.Long.max;
import static java.lang.Math.*;
public class ProblemC {
BufferedReader rd;
ProblemC() throws IOException {
rd = new BufferedReader(new InputStreamReader(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... | n = int(input())
R = [int(i) for i in input().split()]
L = [abs(R[i]-R[i+1]) for i in range(n-1)]
ans = [0 for _ in range(n)]
ans[0] = L[0]
for i in range(1, n-1):
ans[i] = max(L[i], L[i]-ans[i-1])
if i - 2 >= 0:
ans[i] = max(ans[i], L[i]-L[i-1]+ans[i-2])
print(max(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 java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util... |
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 fagain{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] array = new long[n];
for(int i = 0; i < n; i++) {
array[i] = sc.nextInt();
}
long[] a = new long[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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author kronos
*/
public class Main {
public static void main(String[] args) {
InputStream 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.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.InputMismatchException;
public class coco {
/**
* @param args
*/
public static void main(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... | import java.util.*;import java.io.*;import java.math.*;
public class Main
{
public static void process()throws IOException
{
int n=ni();
int[]A=nai(n);
int[]temp=new int[n-1];
for(int i=0;i<n-1;i++)
{
temp[i]=Math.abs(A[i+1]-A[i]);
if(i%2==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;
const int maxn = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
inline int read() {
int ans = 0, flag = 1;
char c;
c = getchar();
while (c < '0' || c > '9') {
if (c == '-') flag = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
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;
const int N = 100005;
int a[N], n;
long long pre[2], suf[2], sum[2];
long long divide(int L, int R) {
if (L == R) {
pre[0] = -a[L];
pre[1] = a[L];
return a[L];
}
int M = (L + R) / 2;
long long aa = divide(L, M);
long long bb = divide(M + 1, R);
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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static int a[];
static long dp[][];
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader;
bufferedReader = new BufferedReader(new InputStre... |
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.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.InputMismatchException;
public class Solution {
public static void main(String[] args){
InputReader in=new InputReader(System.in);
PrintWriter pw=new PrintWriter(System.... |
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.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;
/**
* @author ramilagger
*/
public class Main {
final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
static long f(long a[]) {
int size = a.length;
long max_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... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void uin(T &a, T b) {
if (b < a) {
a = b;
}
}
template <typename T>
void uax(T &a, T b) {
if (b > a) {
a = b;
}
}
const long long maxn = 100 * 1000 + 228;
long long n;
long long a[maxn], b[maxn], pref[maxn];
void solve() {
ios_base::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... | #include <bits/stdc++.h>
using namespace std;
long long f(int *temp, int n) {
long long ans = 0, cur = 0;
for (int i = 0; i < n - 1; i++) {
cur += temp[i];
if (cur < 0) {
cur = 0;
}
ans = max(ans, cur);
}
return ans;
}
int main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < 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.IOException;
import java.io.InputStreamReader;
public class Main {
static int a[];
static long dp[][];
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader;
bufferedReader = new BufferedReader(new InputStre... |
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[100100];
long long b[100100];
long long c[100100];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i < n; i++) {
b[i] = abs(a[i] - a[i + 1]);
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... | import java.io.*;
import java.util.*;
public final class round_407_c
{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static FastScanner sc=new FastScanner(br);
static PrintWriter out=new PrintWriter(System.out);
static Random rnd=new Random();
static int n;
public stati... |
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.*;
import java.math.*;
public class Main{
/*
.
.
.
.
.
.
.
some constants
.
*/
/*
.
.
.
if any
.
.
*/
public static void main(String[] args) throws IOException{
/*
.
.
.
.
.
.
*/
int n=ni();
long arr[]=nla(n);
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... | # Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase
def kadane(arr):
maxsofar=-float('inf')
mx=0
for i in arr:
mx+=i
maxsofar=max(maxsofar,mx)
if mx<0:
mx=0
return maxsofar
def main():
n=int(input())
arr=list(ma... |
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()))
ans=-10**9-1
mini=0
temp=0
for i in range(n-1):
if(i%2==0):temp+=abs(a[i]-a[i+1])
else:temp-=abs(a[i]-a[i+1])
mini=min(mini,temp)
ans=max(ans,temp-mini)
mini=0
temp=0
for i in range(1,n-1):
if(i%2==0):temp-=abs(a[i]-a[i+1])
else:temp+=abs(a[i]-a[i+1])
mini=min(mini... |
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() {
cin.tie(0);
ios_base::sync_with_stdio(0);
long long int N, ref, temp, maxAns = -1;
const int max_size = 100005;
array<array<long long int, 2>, max_size> dp;
vector<long long int> diffs;
cin >> N >> ref;
for (int i = 0; i < N - 1; ++i) {
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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper... |
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 = map(int, raw_input().split())
b = []
for i in range(n - 1):
b += [abs(a[i] - a[i + 1])]
if i % 2:
b[-1] = -b[-1]
def calc(a, n):
sum = 0
res = 0
for i in range(n):
sum = max(0, sum + a[i])
res = max(res, sum)
return res
res = calc(b, n - 1)
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... | import java.util.*;
public class Main {
private static final long INF = (long)1e16;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long[] a = new long[n];
for (int i = 0; i < n; ++i) {
a[i] = in.nextLong(... |
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())
data = map(int, raw_input().split())
def solve(data):
cur = 0
smallest = 0
ret = abs(data[1] - data[0])
for i in xrange(len(data) - 1):
v = abs(data[i] - data[i + 1])
if i % 2 == 0:
cur += v
else:
cur -= v
ret = max(ret, cur -... |
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 A788 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int[] A = new int[N];
for (int n=0; n<N; n++) {
A[n] = in.nextInt();
}
long max = 0;
for (int offset... |
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/env python3
from sys import stdin,stdout
def ri():
return map(int, input().split())
n = int(input())
a = list(ri())
b = [abs(a[i]-a[i+1])*(-1)**i for i in range(n-1)]
ans = 0
s = 0
i = 0
while (i < n-1):
s += b[i]
if s < 0:
s = 0
if i%2 == 0:
i += 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... | //I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.Point;
public class Main{
//a.push_back
public sta... |
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 main {
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
int intLength = input.nextInt();
int[] arrNum = new int[intLength];
long answerImpar = 0;
long sumaImpar = 0;
long answerPar = 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(raw_input())
array = [int(x) for x in raw_input().split()]
da = []
for i in xrange(1,n):
da.append(abs(array[i] - array[i-1]))
mejor = 0
tope = [0,0]
for i in xrange(n-1):
tope[i % 2] += da[i]
tope[(i+1)%2] -= da[i]
if tope[(i+1)%2] < 0:
tope[(i+1)%2] = 0
if tope[i % 2] > mejor:
... |
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>
long long a[100010];
long long dpa[100010];
long long dpb[100010];
long long iabs(long long x) {
if (x < 0) return -x;
return x;
}
int main() {
int n;
scanf("%d", &n);
scanf("%lld", &a[1]);
dpa[1] = 0;
dpb[1] = 0;
long long fuck;
for (int i = 2; i <= n; i++) {
scanf("%lld"... |
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 = 100009;
const long long INF = 1e16;
int n, a[N];
long long s1[N], s2[N];
long long vout = -INF, t1[2], t2[2];
inline int read() {
char c = getchar();
int f = 1, ret = 0;
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
whil... |
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())
lis = list(map(int,input().split()))
ab = [abs(lis[i]-lis[i-1]) for i in range(1,n)]
ev=od=ans=0
for i in range(n-1):
if i%2==0:
ev+=ab[i]
od=max(0,od-ab[i])
else:
ev=max(0,ev-ab[i])
od+=ab[i]
ans=max(ans,ev,od)
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 java.util.*;
import java.io.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class TestClass {
public static void main(String args[] ) throws Exception {
//Scanner hb=new Scanner(System.in);
InputReader hb=new InputReader(System.in);
PrintWriter w=new PrintWriter(Sys... |
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.io.PrintWriter;
/*
* Examples
input
5
1 4 2 3 1
output
3
input
4
1 5 4 7
output
6
*/
public class P789C_Functions_again {
private static PrintWriter pw;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
pw = new PrintWriter(System.o... |
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 kadane(vector<long long> a) {
long long ans = a[0];
long long sum = a[0];
for (int i = 1; i <= n - 2; ++i) {
if (sum < 0) {
sum = a[i];
} else
sum += a[i];
ans = max(ans, sum);
}
return ans;
}
int main() {
cin >> n;
lon... |
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 CF789C {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine()) - 1;
StringTokenizer st = new StringTokenizer(br.readLine());
int[] aa = 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;
int main() {
long long n;
cin >> n;
long long a[n + 1];
for (long long i = 1; i <= n; i++) cin >> a[i];
long long b[n];
for (long long i = 1; i < n; i++) b[i] = abs(a[i] - a[i + 1]);
long long mx[n + 1], mn[n + 1];
mx[n] = 0;
mn[n] = 0;
long long ans = 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 = 1E5 + 10;
int n, A[maxn];
long long Ans, Min, B[maxn];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
for (int i = 1; i < n; i++) A[i] = abs(A[i + 1] - A[i]);
for (int i = 1; i < n; i++) B[i] = (i & 1) ? A[i] : -A[i], 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.*;
/**
* Created by apple on 2017/1/18.
*/
public class Main {
private Scanner in;
public static void main(String[] args) {
new Main().run();
}
long[] a;
long best[][];
private void run() {
in = new Scanner(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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... |
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.*;
public class C789 {
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWriter(System.out);
final long start = System.currentTimeMillis();
new Task1().... |
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.math.MathContext;
import java.util.*;
public class main {
static ArrayList<Integer> prime;
static boolean check[];
static ArrayList<Integer> queue;
public static void main(String[] args) {
InputReader sc=... |
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, math
from sys import stdin, stdout
from collections import deque
from copy import deepcopy
rem = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, raw_input().split())
from sys import maxint
def maxSubArraySum(a, size):
max_so_far = -maxint - 1
max_ending_here = 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... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in Actual solution is at the top
*
* @author ... |
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 ans1 = LLONG_MIN, ans2 = LLONG_MIN, mx1 = 0, mx2 = 0;
vector<long long> v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i];
}
for (int i = 1; i < n; ++i) {
if (i % 2 == 0) {
mx1 = max(mx1 - abs(v[i] - v[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.io.*;
import java.util.*;
public class fagain{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] a = new long[n];
for(int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
long[] dif = new long[n-1];
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.*;
import java.util.*;
//http://codeforces.com/problemset/problem/788/A
//maximum sub array
//minimum sub array
//μ§μ νμ λλ μ?
//ν΄λΉ μΉΈμμ μμλ©΄ 0 μμλ©΄ maxμ ν©μΉλ€?
public class Solution788A {
public static int[] arr = new int[100001];
public static int[] dist = new int[100001];
public static void main(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;
long long n, m, f[1000100][2], a[1000100], c[1000100], ans;
inline int getint() {
int w = 0, q = 0;
char c = getchar();
while ((c < '0' || c > '9') && c != '-') c = getchar();
if (c == '-') q = 1, c = getchar();
while (c >= '0' && c <= '9') w = w * 10 + c - '0', 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;
long long a[100005];
long long d[100005];
long long Min[100005];
long long Max[100005];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n - 1; i++) {
d[i] = abs(a[i + 1] - a[i]);
}
Min[n - 1] = Max[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.io.*;
import java.math.*;
public class Main
{
static class Reader
{
private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
public int read() {if (nu... |
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 kadane(A):
if len(A)==0:
return 0
max_c=A[0]
max_g=A[0]
for i in range(1,len(A)):
max_c=max(A[i],max_c+A[i])
if max_c>max_g:
max_g=max_c
return max_g
def answer(n,A):
b=[]
for i in range(0,n-1):
x=abs(A[i]-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... | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long n;
cin >> n;
long long num[n + 1], dif[n];
for (__typeof(n) i = 1; i <= n; i++) {
cin >> num[i];
}
for (__typeof(n - 1) i = 1; i <= n - 1; i++) {
dif[i] = abs(num[i] - num[i + 1]);
if (i % 2) dif[i] = -dif[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;
const int N = 1e5 + 10;
const double INF = 1e12;
const double eps = 1e-9;
int n;
long long a[N];
long long maxSubArray() {
long long ret = a[0], cur = a[0];
for (int i = 1; i < n - 1; i++) {
cur = max(a[i], cur + a[i]);
ret = max(ret, cur);
}
return ret;
}
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 con2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
long[] a = new long[n-1];
long l = in.nextLong();
for (int i = 1; i < n; i++) {
long c = in.nextLong();
a[i-1] = Math.abs(l - c);
l = c;
}
long ma... |
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() {
std::ios_base::sync_with_stdio(false);
int n;
cin >> n;
long long ar[n], d[n];
for (int i = 0; i < n; i++) {
cin >> ar[i];
}
for (int i = 0; i < n - 1; i++) d[i] = abs(ar[i] - ar[i + 1]);
long long ar1[n - 1], ar2[n - 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 math
from collections import defaultdict as dd
def main():
n = int(input())
A = list(map(int, input().split()))
# print(A)
B = []
for i in range(1, len(A)):
B.append(abs(A[i]-A[i-1]))
# print(B)
Dp = dd(int)
Dm = dd(int)
Dp[0]=0
MAX = 0
for i in range(... |
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 C {
static final int INF = (int)2e9;
public static void main(String[] args) throws Exception{
Scanner sc = new 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.util.*;
public class CF_788_A {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;++i)
arr[i]=sc.nextInt();
long diff[]=new long[n-1];
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... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> v(n - 1);
for (int i = 0; i < n - 1; i++) {
v[i] = abs(a[i] - a[i + 1]);
}
vector<vector<long long>> dp(n + 1, vector<long long>(2));
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 n;
int a[110000];
long long b[110000];
long long c[110000];
long long d[110000];
int getZ(int x) {
if (x % 2 == 0)
return 1;
else
return -1;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; ++i) cin >> 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 java.util.*;
import java.io.*;
public class ProblemA {
public static void main(String[] args) {
// TODO Auto-generated method stub
FastScanner input = new FastScanner();
int n = input.nextInt();
long[] arr = input.readLongArray(n);
long[] arr1 = new long[n-1];
long[] arr2 = new long[n-1];
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>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<long long> vec(n + 1);
for (int i = 1; i <= n; i++) cin >> vec[i];
vector<long long> a;
for (int i = 1; i < n; i++) {
if (i & 1)
a.push_back(abs(vec[i] - vec[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 a[100005], b[100005];
int main() {
int n, i;
cin >> n;
for (i = 0; i < n; i++) scanf("%d", a + i);
for (i = 0; i < n - 1; i++) b[i] = abs(a[i] - a[i + 1]);
for (i = 1; i < n - 1; i += 2) b[i] = -b[i];
n--;
long long cur = 0, ans = 0;
for (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.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Tas... |
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.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public ... |
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 Solution {
static FastScanner scr=new FastScanner();
// static Scanner scr=new Scanner(System.in);
static PrintStream out=new PrintStream(System.out);
static StringBuilder sb=new StringBuilder();
static class pair{
int x;int y;
pair(int 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... | #include <bits/stdc++.h>
using namespace std;
long long tabela[(int)1e5 + 100];
long long dp(vector<long long> &second, long long idx, long long L) {
if (tabela[idx] != -1) return tabela[idx];
if (idx <= L) return tabela[idx] = second[L];
return tabela[idx] = max(second[idx], second[idx] + dp(second, idx - 1, 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.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;
/*
* Java Input / Output Cla... |
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
from io import BytesIO, IOBase
from collections import Counter, deque
import math
'''import time
import collections
import itertools
import timeit
import random
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 sys
n = int(input())
a = list(map(int, input().split()))
d = []
for i in range(1,n):
d.append(abs(a[i] - a[i - 1]))
evencur = 0;
sgn = 1;
ans = 0;
for i in range(len(d)):
evencur += d[i] * sgn;
sgn *= -1;
ans = max(evencur, ans)
if evencur < 0:
evencur = 0;
sgn = 1;
evencur = ... |
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[100005], b[100005];
long long pmax[100005], pmin[100005];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
for (int i = 1; i < n; i++) b[i] = abs(a[i] - a[i + 1]);
for (int i = 2; i < n; i += 2) b[i] *= -1;
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>
using namespace std;
long long powmod(long long a, long long l, long long md) {
a %= md;
long long res = 1;
while (l) {
if (l & 1) res = res * a % md;
l /= 2;
a = a * a % md;
}
return res;
}
long long binpow(long long a, long long l) {
long long res = 1;
while (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... | n = int(input())
a = list(map(int, input().split()))
def getAns(b):
res = 0
now = 0
for x in b:
if now > 0:
now += x
else:
now = x
res = max(res, now)
return res
b = [abs(a[i] - a[i + 1]) * (-1 if i & 1 else 1) for i in range(n - 1)]
res = getAns(b)
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... | n = int(raw_input())
arr=map(int,raw_input().split(" "))
arr1=[]
arr2=[]
mult=1
for i in range(len(arr)-1):
val = abs(arr[i]-arr[i+1])
arr1.append(mult*val)
arr2.append(-1*mult*val)
mult=mult*-1
max1=0
max2=0
curr=0
for val in arr1:
curr=curr+val
if curr>max1:
max1=curr
if curr<0:
curr=0
curr=0
for val in ar... |
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 Div2_407C {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int numI = Integer.pars... |
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 os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.wr... |
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.*;
import java.awt.Point;
// SHIVAM GUPTA :
//NSIT
//decoder_1671
// STOP NOT TILL IT IS DONE OR U DIE .
// U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................
// ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 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... | import java.util.*;
import java.io.*;
public class test{
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();
boolean even=true;
int aa=0;
//even
... |
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 static java.lang.Math.*;
import static java.util.Arrays.*;
public class recc788a {
static BufferedReader __in;
static PrintWriter __out;
static StringTokenizer input;
public static void main(String[] args) throws IOException {
__in = new BufferedRe... |
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 cp;
import java.io.*;
import java.util.*;
public class Cf_three {
static long max_sum(ArrayList<Long> arr) {
long cur_sum=0;long best_sum=0;
for (int i = 0; i < arr.size(); i++) {
cur_sum=Math.max(arr.get(i), cur_sum+arr.get(i));
best_sum=Math.max(best_sum, cur_sum);
}
return best_sum;
}
pub... |
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, k, i, sum1, sum2, dummy;
cin >> n;
vector<long long int> v, dp;
for (i = 0; i < n; i++) {
cin >> k;
v.push_back(k);
}
for (i = 0; i < n - 1; i++)
if (i % 2 == 0)
dp.push_back(fabs(v[i] - v[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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Functions
{
static long DP[][];
static int arr[];
static int n;
public static long solve(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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokeni... |
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;
/*
* 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.
*/
/**
*
* @author root
*/
public class... |
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... | ### @author egaeus
### @mail jsbeltran.valhalla@gmail.com
### @veredict
### @url https://codeforces.com/problemset/problem/788/A
### @category
### @date 13/11/2019
def f(list):
listA = []
listB = [0]
res = 0
for i in range(len(list)):
res = max(res, list[i])
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... | n=int(input())
b=list(map(int,input().split()))
s1=0
s2=0
j=0
c=[]
while(j<n-1):
c.append(abs(b[j+1]-b[j]))
j+=1
j=0
p=0
r=0
while(j<(n-1)):
if (j+1)<(n-1):
r=max(c[j]-c[j+1],r+c[j]-c[j+1])
p = max(p, r +c[j + 1])
else:
r=max(c[j],r+c[j])
p=max(p,r)
j+=2
j=1
r=0
wh... |
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 Pradyumn Agrawal coderbond0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.