Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; long long n, L, R, l[300005], r[300005]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } int ans = abs(L - R), pm = 0; for (int i = 1; i <= n; i++) { L = L - l[i] + r[i]; R = R - r[i] + l[i]; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) a = n * [0] left_count, right_count = 0, 0 cur_max, flag = 0, 0 for i in range(n): x = list(map(int, input().split())) a[i] = x left_count += x[0] right_count += x[1] if abs(x[0] - x[1]) > cur_max: cur_max = abs(x[0] - x[1]) mdl = abs(left_count - right_count) for j in range...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int ans(vector<pair<int, int> > v, int n) { int lsum = 0, rsum = 0, ns, a; for (int i = 0; i < n; i++) { lsum += v[i].first; rsum += v[i].second; } ns = abs(lsum - rsum); int msum = ns; bool flag = false; for (int i = 0; i < n; i++) { if (msum < ab...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int kN = 1e5 + 1; int l[kN], r[kN]; int n; int main(int argc, char** argv) { ios_base::sync_with_stdio(false); cin >> n; int mx_ind = 0, l_sm = 0, r_sm = 0; for (int i = 0; i < n; ++i) { cin >> l[i] >> r[i]; l_sm += l[i], r_sm += r[i]; } int bt = a...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
if __name__ == "__main__": n = input() a = [map(int, raw_input().split()) for _ in range(n)] L = sum([x for x, y in a]) R = sum([y for x, y in a]) max_index = -1 max_res = abs(L - R) for i in range(n): x, y = a[i] if x > y: if abs(R - L + 2*(x - y)) > max_res: ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=input('') def mod(c): if c>0: return c else: return -c diff=0 dl=[] right,left=0,0 for i in range(n): t=list(map(int,str(raw_input('')).split(' '))) dif=t[0]-t[1] diff+=dif dl+=[dif] r=1 l=-1 if min(dl)<0: r=min(dl) if max(dl)>0: l=max(dl) ir=-1 il=-1 for i in range(len...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Collection; import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; int[] b = new int[n]; int ans = 0; int l = 0; int r = 0; ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(raw_input()) cols = [] for i in xrange(n): cols.append([int(x) for x in raw_input().split()]) totalL = 0 totalR = 0 for c in cols: totalL += c[0] totalR += c[1] beauty = totalL - totalR ans = -1 anss = -1 for i in xrange(len(cols)): L, R = cols[i] newb = beauty - L + R + R - L if ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
t=int(input('')) q=0;s=0;e=0;f=0;b=0;c=0;x=0;g=0;r=0;j=0;r1=0;q1=0;u=0;y=0;a1=0;a2=0 for z in range(0,t): a=(list(map(int, input().split()))) b+=a[0];c+=a[1] if(a[0]-a[1]>0): if (a[0]-a[1])>a1: q=a[0];u=z;q1=a[1];a1=a[0]-a[1] if(a[1]-a[0]>0): if a[1]-a[0]>a2: x=z;...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
def get_data(): output = [[0, 0]] n = int(input()) for i in range(n): a, b = input().split() a = int(a) b = int(b) output[0][0] += a output[0][1] += b output.append([a, b]) return output data = get_data() def check_beauty(): diff = abs(data[0][0...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; import java.io.*; public class Main { static Scanner scan = new Scanner(System.in); static PrintStream out = new PrintStream(System.out); static int left, right, ind, val; static int n, sum, a, b, c; static int[][] arr; public static void main (String[] args) { n = scan.ne...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> int abss(int a); int main() { int size; scanf("%d", &size); int colunm[size + 10][2]; int i; int left = 0, right = 0; for (i = 1; i <= size; i++) { scanf("%d %d", &colunm[i][0], &colunm[i][1]); left += colunm[i][0]; right += colunm[i][1]; } int abs = abss(left - righ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int b[100005]; int a[100005]; int c[100005]; int main() { int n, lmax = 0, rmax = 0, l, r; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; lmax += a[i]; rmax += b[i]; } int ans = 0; int j = 0; ans = abs(lmax - rmax); for (int i = 1;...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); int X = 0, Y = 0; int min = 0, min_i = 0, max = -500, max_i = 0; for (int i = 0; i < n; i++) { int x, y; scanf("%d %d", &x, &y); X += x, Y += y; if (min >= (x - y)) { min = (x - y); min_i = i + 1; } if (max <= (x...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(raw_input()) a=[] l=r=ans=chk=0 for i in range(n): x,y=map(int,raw_input().split()) l,r=l+x,r+y a.append((x,y)) chk=abs(l-r) for p,i in enumerate(a): tmp=abs((l-i[0]+i[1])-(r-i[1]+i[0])) if chk<tmp: ans=p+1 chk=tmp print ans
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long l = 0, r = 0, n; cin >> n; vector<pair<long long, long long> > v(n); vector<long long> t(n); for (int i = 0; i < n; ++i) { cin >> v[i].first >> v[i].second; t[i] = v[i].first - v[i].second; l += v[i].first; r += v[i].second; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; vector<long long> v; vector<long long> vv; set<long long> st; long long x, y, z; string s, s1, s2, s3, s4, s5; void memset_ll(long long a[], long long v, long long n) { for (long long i = 0; i < n; i++) a[i] = v; } void memset_s(char a[], char v, long long n) { for (lon...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 100003; int n, a[N], b[N]; int main() { int l = 0, r = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i], &b[i]); l += a[i], r += b[i]; } int an = 0, t = abs(l - r), l1, r1; for (int i = 1; i <= n; i++) { l1 = l, r1...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
from sys import stdin,stdout,setrecursionlimit,maxint,exit #setrecursionlimit(2*10**4) def listInput(): return map(long,stdin.readline().split()) def printBS(li): for i in xrange(len(li)-1): stdout.write("%d "%li[i]) stdout.write("%d\n"%li[-1]) def sin(): return stdin.readline().rstrip() n=input() li=[] l,r=0,0 f...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.util.*; public class b733 { public static void main(String[] args){ FasterScanner sc=new FasterScanner(); PrintWriter pw =new PrintWriter(System.out); int n,a[],i,c; n=sc.nextInt(); a=new int[n]; for(i=0;i<n;i++) a[i]=sc.nextInt()-sc.nextInt(); int s=a[0]; for(i=1;i<n;i...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int> > v; v.clear(); int x, y; int neg = 0, pos = 0, lsum = 0, rsum = 0; int maxx = 0, minn = 0, idx1 = 0, idx2 = 0, maxi = 0, idd = 0; for (int i = 0; i < n; i++) { cin >> x >> y; if (x - y >= maxx && x...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, max = 0, min = 0, min_c = 0, max_c = 0, sum_l = 0, sum_r = 0; cin >> n; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; sum_l += l; sum_r += r; if (i == 0) max = l - r; if (max < (l - r)) { max = l - r; ma...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int[] l = new int[n], r = new int[n]; ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; import java.io.*; import javafx.util.Pair; public class Param { public static void main( String[]args) { Scanner param = new Scanner(System.in); int n=param.nextInt(); int a=0; int b=0; int pos=0; int neg=0; int diff1=0; int diff2=0; int arr[]...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) l_lst=[] r_lst=[] for i in range(n): l,r=list(map(int,input().split())) l_lst.append(l) r_lst.append(r) c_beauty=abs(sum(l_lst)-sum(r_lst)) index=0 left=sum(l_lst) right=sum(r_lst) for i in range(n): if abs((left-l_lst[i]+r_lst[i])-(right+l_lst[i]-r_lst[i]))>c_beauty: c_beauty=abs...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
//package pkg378.div2; import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x[] = new int[100001]; int max = 0; for (int i = 0; i < n; i++) { int a = sc.nextI...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, beauty = 0, index = 0, L = 0, R = 0; cin >> n; int l[n], r[n]; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } beauty = abs(L - R); for (int i = 0; i < n; i++) { if (abs(L - R - 2 * (l[i] - r[i])) ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class ans1 { public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
from collections import Counter import string import math import sys def array_int(): return [int(i) for i in sys.stdin.readline().split()] def vary(number_of_variables): if number_of_variables==1: return int(sys.stdin.readline()) if number_of_variables>=2: return map(int,sys.stdin.readline(...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.InputStreamReader; import java.io.File; import java.io.FileNotFoundException; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputSt...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import re import sys import time def read(t=None): string = raw_input() return string if t is None else [t(x) for x in string.split()] def swap(tp, lsm, rsm): left, rght = tp lsm = lsm - left + rght rsm = rsm - rght + left return abs(lsm-rsm) def solve(): n = int(read()) a = [] for i in xrange(n): left, r...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, m, count = 0, c = 0, L = 0, R = 0, result = 0, l1, r1; int a[100002], b[100002]; cin >> n; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; L = L + a[i]; R = R + b[i]; } result = abs(L - R); for (i = 0; i < n; i++) { l1 ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; import java.io.*; import java.math.*; public final class Solution { static int[] arr; public static void main(String[] args) { Reader input = new Reader(); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = input.nextInt(); int...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int t1, t2; int s1 = 0, s2 = 0; int ki = 0; std::vector<pair<int, int>> v; int pos = 0; for (int i = 0; i < n; ++i) { cin >> t1 >> t2; v.push_back({t1, t2}); s1 += t1; s2 += t2; } ki = abs(s2 - s1); for (in...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(raw_input()) cols = [] l, r = 0, 0 for i in xrange(0, n): cols.append(tuple(int(x) for x in raw_input().split())) l += cols[-1][0] r += cols[-1][1] diff = abs(l - r) currentDiff = 0 index = -1 for i in xrange(0, len(cols)): currentDiff = abs((l - cols[i][0] + cols[i][1]) - ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; public class b { private static final boolean localEnv = false; private void solve(Scanner in, PrintWriter out) { int n = in.nextInt(); int[] l = new int[n], r = ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
def GetIndex(soldiers): L=0 R=0 for i in soldiers: L += int(i[0]) R += int(i[1]) max_beauty = abs(L-R) index = 0 for i in range(len(soldiers)): l=L r=R l -= int(soldiers[i][0]) r -= int(soldiers[i][1]) l += int(soldiers[i][1]) r...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long l[n], r[n], L = 0, R = 0; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } long long LT = L, RT = R, mx = abs(L - R), c = 0; for (int i = 0; i < n; i++) { L -= l[i]; L += r[i...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
t = input() legs = [] l = 0 r = 0 for i in range(t): s = map(int,raw_input().split()) legs.append(s) l += s[0] r += s[1] ans = abs(l-r) ind = -1 for i in range(t): x = l-legs[i][0]+legs[i][1] y = r-legs[i][1]+legs[i][0] if abs(x-y)>ans: ans = abs(x-y) ind = i print ind+1
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
def main(): no_columns = int(raw_input()) data = [] for i in xrange(no_columns): l, r = map(int, raw_input().split(" ")) data.append((l, r)) total_beauty = beauty(data) max_beauty = abs(total_beauty) to_swap = 0 for sw in xrange(no_columns): b = abs(total_beauty ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.awt.Point; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.util.Comparator; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigIn...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), l = 0, r = 0, ind = 0; int[][] a = new int[n][2]; for (int i = 0; i < n; i++) { l += a[i][0] = in.nextInt(); r += a[i]...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, L = 0, R = 0, a, diff = 0, ans = 0, b; cin >> n; long long int l[n + 5], r[n + 5]; for (long long int i = 0; i < n; i++) { cin >> l[i]; cin >> r[i]; L += l[i]; R += r[i]; } diff = abs(L - R); for (i = 0; i < n; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, lsum = 0, rsum = 0; cin >> n; int l[n], r[n], dp[n]; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; lsum += l[i]; rsum += r[i]; dp[i] = l[i] - r[i]; } int diff = lsum - rsum; int b = abs(diff), c = 0; for (int i = 0; i...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> s; for (int i = 1; i <= n; i++) { int a, b; cin >> a >> b; s.push_back(a - b); } int s1 = 0, s2 = 0; for (const int &x : s) { if (x < 0) s1 += x;...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class Parade { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] r = new int[n+1], l = new int[n+1]; int totalL = 0, totalR = 0; for (int i = 1; i <= n; i++) { l[i] = sc.nextInt(); r[i] = sc.nextInt(); tota...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import sys def abs(x): if x > 0: return x else: return -x def beauty(x): return (x[1] - x[2]) def max_beauty(x): return x[1] def readLR(f, i): l, r = (int(x) for x in f.readline()[:-1].split(' ')) return i, l, r n = int(sys.stdin.readline()[:-1]) lr = [readLR(sys.stdin, i) f...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
/* * 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 ssaxena36 FI/O from @uwi * */ import java.io.*; import java.util.*; public class Hello { void solve() { ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) l = [] r = [] suml = 0 sumr = 0 for i in range(n): a, b = input().split(' ') l.append(int(a)) r.append(int(b)) suml += int(a) sumr += int(b) diff = abs(suml-sumr) index = -1 for i in range(n): if abs((suml-l[i]+r[i])-(sumr-r[i]+l[i])) > diff: diff = abs((suml-l[i]+r[i]...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class Div_378_2 { public static void main(String[] args) { // TODO Auto-generated method stub int n; int[] l, r, ex; Scanner in = new Scanner(System.in); n = in.nextInt(); l = new int[n]; r = new int[n]; ex = new int[n]; int sumBeauty = 0, maxBeauty = -1, maxbeaut...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
##n = int(input()) ##a = list(map(int, input().split())) ##print(" ".join(map(str, res))) n = int(input()) l = [] r = [] lsum = 0 rsum = 0 for i in range(n): [a, b] = list(map(int, input().split())) l.append(a) r.append(b) lsum += a rsum += b best = abs(lsum-rsum) besti = -1 for i in range(n): ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int l[100009], r[100009]; int sum1 = 0, sum2 = 0; int suml1[100009], suml2[100009], sumr1[100009], sumr2[100009]; int main() { int n; cin >> n; suml1[0] = 0; sumr1[0] = 0; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; suml1[i] = suml1[i - 1] + l[i]; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n; int ans = 0; int cha = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { int x1, x2; scanf("%d%d", &x1, &x2); a[i] = x1 - x2; cha += a[i]; } int tmp = cha; int tmp1 = tmp; for (int i = 1; i <= n; i++) { ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int l[n], r[n]; int L = 0, R = 0; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; L += l[i], R += r[i]; } int ans = abs(L - R); int col = 0; for (int i = 0; i < n; i...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
from sys import stdin, stdout n = int(stdin.readline()) challengers = [] l, r = 0, 0 for i in range(n): a, b = map(int, stdin.readline().split()) challengers.append((a, b)) l += a r += b ans = abs(r - l) label = 0 for i in range(n): a, b = challengers[i] if abs((r - b + a) - (l - a + b)) > ans...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) count = [0, 0] A = [] index = 0 good = False for i in range(n): l, r = map(int, input().split()) count[0] += l count[1] += r A.append((l, r)) beuty = abs(count[0] - count[1]) for i in range(n): if abs((count[0] + (A[i][1] - A[i][0])) - (count[1] + (A[i][0] - A[i][1]))) > beuty: ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { StdIn scn = new StdIn(); int n = scn.nextInt(); ArrayList<Integer> left = new ArrayList<Integer>(); ArrayList<Integer> right = new ArrayList<Integer>(); ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> l(n), r(n); int u = 0, v = 0; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; u += l[i]; v += r[i]; } int ma = abs(u - v); int ind = 0; for (int i = 0; i < n; i++) { swap(l[i], r[i]); int p =...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class Parade { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int li[] = new int[n]; int ri[] = new int[n]; int L = 0,R = 0; int min = Integer.MAX_VALUE, max = Integer.MIN_VALU...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 100 + 10; int n; long long l[N], r[N], L, R, maxi = 0, x; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } maxi = abs(L - R); for (int i = 0; i < n; i++) if (abs(L - l[i] + r[i] ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int MYDD = 1103 + 1e5; int main() { int n, l[MYDD], r[MYDD], sl = 0, sr = 0; scanf("%d", &n); for (int j = 0; j < n; j++) { scanf("%d %d", &l[j], &r[j]); sl += l[j]; sr += r[j]; } int maxk = abs(sl - sr), ans = 0; for (int j = 0; j < n; j++) { ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import math l = 0 r = 0 n= int(input()) max = -1 j = 0 x = 0 y = 0 str2=[] for i in range(n): str1 = input().split() str2.append(str1) l +=int(str1[0]) r +=int(str1[1]) max = abs(l-r) for i in range(n): if abs((l-int(str2[i][0])+ int(str2[i][1])) - (r+int(str2[i][0])-int(str2[i][1]))) >...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) c = [0] * n L = R = 0 for i in range(n): l, r = map(int, input().split()) c[i] = r - l L += l R += r Max = abs(L - R) ans = 0 for i in range(n): cur = abs(L - R + 2 * c[i]) if cur > Max: Max = cur ans = i + 1 print(ans)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve(std::istream& in, std::ostream& out) { int n; in >> n; vector<pair<long long, long long>> cl; long long la = 0; long long ra = 0; long long mx = 0; int ans = 0; for (int i = 0; i < n; i++) { long l...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws FileNotFoundException, IOException { InputStream inputStream = System.in; // InputStream inputStream = new FileInputStream("dijkstra.in"); OutputStream outputStream = System.out; // ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=[0]+[sum(map(int,('-'+input()).split())) for i in range(int(input()))] s,a,b=sum(n),min(n),max(n) print(n.index(b if s<a+b else a))
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#!/usr/bin/env python # -*- coding: utf-8 -*- n = int(raw_input()) L = 0 R = 0 a = [] for i in xrange(0, n): l, r = [int(i) for i in raw_input().split()] L += l R += r a.append([l, r]) best_beauty = abs(L - R) v = 0 for i in xrange(0, n): new_L = L new_R = R new_L -= a[i][0] new_L += ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.Arrays; i...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
# print ("Input n") n = int(input()) suml = 0 sumr = 0 biggestleftinc = 0 blindex = -1 biggestrightinc = 0 brindex = -1 for i in range(n): l, r = (int(x) for x in input().split()) suml += l sumr += r diff = abs(l-r) if l > r and diff > biggestleftinc: biggestleftinc = diff blindex = ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int a[200000][2] = {}; int n, m = 0, q = 0, l = 0, k = 0, p2 = 0, s1 = 0, s2 = 0, p1 = 0, r = 0, b = 0, num11 = 0, num12 = 0, num21 = 0, num22 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; r += a[i][0]; b +...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int l[100005]; int r[100005]; int main() { #pragma warning(disable : 4996) int n, sl = 0, sr = 0, a, a1; cin >> n; for (int i = 1; i <= n; i++) { scanf("%d%d", &l[i], &r[i]); sl += l[i]; sr += r[i]; } a = abs(sl - sr); a1 = 0; for (int i = 1; i <= ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import math n = int(input()) L = 0 R = 0 LI = [] RI = [] for i in range(n): a, b = map(int, input().split()) L += a R += b LI.append(a) RI.append(b) best = math.fabs(L - R) LT = L RT = R k = 0 for i in range(n): LT = L - LI[i] + RI[i] RT = R - RI[i] + LI[i] temp = math.fabs(LT - RT) ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=input() arr=[0]*n L,R=0,0 for i3 in xrange(n): arr[i3]=map(int,raw_input().split()) L+=arr[i3][0] R+=arr[i3][1] ans=abs(L-R);idx=-1 for i in xrange(n): l=L-arr[i][0]+arr[i][1] r=R-arr[i][1]+arr[i][0] if abs(l-r)>ans: ans=abs(l-r) idx=i print idx+1
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) a=[] sumi=0 left_big=0 left_big_index=-1 right_big=0 right_big_index=-1 for i in range(n): x,y=map(int,input().split()) a.append([x,y]) difference=x-y sumi+=difference if difference>0: if difference>left_big: left_big=difference left_big_index=i else: if abs(difference)>right_big: righ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; import java.io.*; public class Parade { /************************ SOLUTION STARTS HERE ***********************/ private static void solve(FastScanner s1, PrintWriter out){ int N = s1.nextInt(); int L[] = new int[N]; int R[] = new int[N]; int LSum = 0 , RSum = 0; for(int i=0;...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import math R = 0 L = 0 r = [] l = [] n = int(input()) for i in range(n): temp = str(raw_input()) temp_l = int(temp.split(" ")[0]) temp_r = int(temp.split(" ")[1]) R += temp_r L += temp_l r.append(temp_r) l.append(temp_l) min_index = n + 1 beuty = math.fabs(L - R) for i in range(n): ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
from sys import * input = stdin.readline n = int(input()) arr = [] arr2 = [] l = 0 r = 0 for _ in range(n): ll = list(map(int, input().split())) arr.append(ll) arr2.append([ll[1], ll[0]]) l += ll[0] r += ll[1] bu = abs(l-r) ans = 0 for i in range(n): a, b = arr[i][0], arr[i][1] smh = abs((l ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int> > v; v.clear(); int x, y; int neg = 0, pos = 0, lsum = 0, rsum = 0; int maxx = 0, minn = 0, idx1 = 0, idx2 = 0, maxi = 0, idd = 0; for (int i = 0; i < n; i++) { cin >> x >> y; if (x - y >= maxx && x...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
from queue import PriorityQueue fmap = lambda f,l: list(map(f,l)) parse_int = lambda: fmap(int, input().split()) prl, prr = 0, 0 il, ir = 0,0 lsum, rsum = 0,0 for idx in range(int(input())): l, r = parse_int() lsum += l rsum += r if r-l > prl: il = idx prl = r-l if l-r > prr: ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner scan=new ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int li[n], ri[n]; int l = 0, r = 0; for (int i = 0; i < n; i++) { cin >> li[i] >> ri[i]; l += li[i]; r += ri[i]; } int index = 0; int beaut = abs(l - r); for (int i = 0; i < n; i++) { if (abs(l - r - 2 * li[i] ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import sys n = int(sys.stdin.readline().split()[0]) L = 0 R = 0 diff = [] for _ in range(n): [l, r] = [int(x) for x in sys.stdin.readline().split()] L += l R += r diff.append(l - r) opt = abs(L - R) res = 0 if abs(R - L + 2 * min(diff)) > opt: opt = abs(R - L + 2 * min(diff)) res = diff.index(min(diff)) + 1 ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, M = 4e6 + 10, inf = 1e9 + 10, mod = 1e9 + 7; const long long INF = 1e18 + 10; int a[N], b[N]; int main() { int n; int maxx1 = -1, pos1 = 0; int maxx2 = -1, pos2 = 0; int sum1 = 0, sum2 = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; /** * Created by chao on 16/11/13. */ public class A { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); String s =...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) X = [] Y = [] Tot_x=0 Tot_y=0 for i in range(n): x,y = map(int,input().split()) X.append(x); Tot_x += x Y.append(y); Tot_y += y Mi = abs(Tot_x-Tot_y) Max = Mi dist = 0 for i in range(n): if (Max < abs(Tot_y-Tot_x+2*(X[i]-Y[i]))): Max = abs(Tot_y-Tot_x+2*(X[i]-Y[i])) ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; long long int n, m, a, c = 0, l[100010], r[100010], s[100010], p; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; s[i] += l[i] - r[i]; c += s[i]; } m = c; for (int i = 1; i <= n; i++) { if (abs(c - 2 * s[i]) > abs(m)) { ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = input() li = 0 ri = 0 lt = 0 rt = 0 lmax = 0 rmax = 0 for i in range(n) : l,r = map(int, raw_input().split()) diff = l-r if diff < 0 : rt += -diff if rmax < -diff : rmax = -diff ri = i+1 else : lt += diff if lmax < diff : lm...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
num = int(input()) a = [0]*num b=[0]*num sum1=sum2=0 for i in range(0,num): a[i],b[i]= tuple(int(i) for i in input().strip().split(" ")) sum1 = sum(a) sum2 = sum(b) mx = abs(sum1-sum2) index = 0 for i in range(0,num): sum1 = sum1-a[i]+b[i] sum2 = sum2-b[i]+a[i] if(mx< abs(sum1-sum2)): mx = abs(...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; void swapArray(int array1[], int element1, int array2[], int element2) { int temp; temp = array1[element1]; array1[element1] = array2[element2]; array2[element2] = temp; } int main() { int n; cin >> n; int* l = new int[n]; int* r = new int[n]; int max = 0,...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, count = 0, suml = 0, sumr = 0, index = 0; cin >> n; long long l[n], r[n]; for (long long i = 0; i < n; i++) { cin >> l[i] >> r[i]; suml += l[i]; sumr += r[i]; } long long sum = abs(suml - sumr), a, b; for (long long i = 0;...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int n; int a[100010]; int b[100010]; int main() { long long sum_l = 0, sum_r = 0; int ans = 0; int count = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &a[i], &b[i]); sum_l += a[i]; sum_r += b[i]; } count = abs(sum_l - sum_r); ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n, l = 0, r = 0, k = 0, x = -1; cin >> n; int a[n][3]; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; l += a[i][0]; r += a[i][1]; } k = abs(l - r); for (int i = 0; i < n; i++) { a[i][2] = abs((l - a[i][0] + a[i][1]) -...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = input() A = [map(int,raw_input().split()) for x in range(n)] L = 0 R = 0 for x in A: L += x[0] R += x[1] best = abs(L-R) which = None for i,x in enumerate(A): l = L r = R l -= x[0] r -= x[1] l += x[1] r += x[0] if abs(l-r) > best: best = abs(l-r) which = i+1 if which == None: print 0 else: print whi...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
read = lambda: map(int, input().split()) n = int(input()) l, r = [0] * n, [0] * n L = R = 0 for i in range(n): l[i], r[i] = read() L += l[i] R += r[i] Max = abs(L - R) ans = 0 for i in range(n): cur = abs((L - l[i] + r[i]) - (R - r[i] + l[i])) if cur > Max: Max = cur ans = i + 1 prin...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; bool vovel(char c) { return c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y'; } vector<pair<long long int, long long int>> v; int main() { long long int N, L, R; long long int cntL = 0, cntR = 0; cin >> N; for (long long int i = (0); i < (N); +...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
//package codeforces; import java.util.Scanner; /** * Created by nitin.s on 09/12/16. */ public class Parade { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int sumL = 0; int sumR = 0; int index = -1; int[] a =...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) cols = [] for i in range(n): cols.append(list(map(int, input().split()))) left = 0 right = 0 for col in cols: left += col[0] right += col[1] best = -1 max_raze = abs(right - left) for i in range(n): _sleft = left - cols[i][0] + cols[i][1] _sright = right - cols[i][1] + cols[i][0] if abs(_...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; public class parade { static class Parade{ int left; int right; int dif; Parade(int left,int right){ this.left=left; this.right=right; this.dif=Math.abs(left-right); } } public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class B733 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int[] L = new int[N]; int[] R = new int[N]; for (int n=0; n<N; n++) { L[n] = in.nextInt(); R[n] = in.nex...
JAVA