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
n=input() left,right=[],[] for x in range(n): i,j=map(int,raw_input().strip().split(" ")) left.append(i) right.append(j) sl,sr,ind=sum(left),sum(right),-1 m=abs(sl-sr) for i in range(n): ssl=sl-left[i] ssr=sr-right[i] ssl=ssl+right[i] ssr=ssr+left[i] if(abs(ssl-ssr)>m): ind=i ...
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(): a = int(input()) b = [] result = (0 , 0) result2 = (0 , 0) list1 = [] list2 = [] for i in range(a): k = input() k = k.split() list1.append(int(k[0])) list2.append(int(k[1])) left = 0 right = 0 for i in range(a): if list1[i]>list...
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()) num = [list(map(int, input().strip().split())) for i in range(n)] L, R = sum([x[0] for x in num]), sum([x[1] for x in num]) pre = L-R ans = abs(pre) ind = -1 for i,x in enumerate(num): cur = abs(pre+2*(x[1]-x[0])) #print(ans, cur) if cur > ans: ans,ind = cur,i print(ind+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
a=int(input()) lx=[] ly=[] for i in range(a): x,y=map(int,input().split()) lx.append(x) ly.append(y) dist=0 mn=abs(sum(lx)-sum(ly)) op=sum(lx) up=sum(ly) for i in range(a): if abs(op-lx[i]+ly[i]-(up-ly[i]+lx[i]))>mn: mn=abs(op-lx[i]+ly[i]-(up-ly[i]+lx[i])) dist=i+1 print(dist)
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()) 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
n = input() L = 0 R = 0 a = [] for i in range(n): l, r = map(int,raw_input().split()) R += r L += l a.append(r-l) maxv = abs(L-R) maxp = 0 for i in range(n): if (abs(L - R + 2 * a[i]) > maxv): maxv = abs(L - R + 2 * a[i]) maxp = i+1 print maxp
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.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] a = new int[n][2]; int L = 0;int R=0; for(int i=0;i<n;i++){ int var1 = sc.nextInt(); int var2= sc.nextInt(); L...
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 buf = sys.stdin.readlines() n = int(buf[0]) data = [[int(x) for x in line.split(" ")] for line in buf[1:1 + n]] L = R = 0 for l, r in data: L += l R += r B = abs(L - R) m = B best = 0 col = 1 for l, r in data: _L = L - l + r _R = R - r + l _B = abs(_L - _R) if _B > m: m =...
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; vector<pair<int, int>> v; int main() { int n; cin >> n; int ansR = 0, ansL = 0, P = 0, pos = 0; for (int i = 0; i < n; i++) { int l, r; cin >> r >> l; v.push_back(make_pair(r, l)); ansR += r; ansL += l; P = fabs(ansR - ansL); } for (int 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[101000], b[101000]; int main() { int n; scanf("%d", &n); int suma = 0, sumb = 0; for (int i = 0; i < n; i++) { scanf("%d%d", a + i, b + i); suma += a[i]; sumb += b[i]; } int id = 0; int ma = abs(suma - sumb); 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
n = int(input()) l, r = [], [] for i in range(n): a, b = [int(x) for x in input().split()] l.append(a) r.append(b) sl, sr = sum(l), sum(r) score = abs(sl-sr) maxscore = score index = 0 for i in range(n): atual = abs((sl-l[i]+r[i]) - (sr-r[i]+l[i])) if atual > maxscore: maxscore = atual ...
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 cftwo{ 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 right = 0; int left = 0; int numofmax = 0; for(int i = 0; i < n; i++){ a[i] = in.nextInt()...
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 mod(a,b): if a > b: return a-b else: return b-a n = int(raw_input()) data = [] for i in range(n): l = raw_input().split(" ") l = [int(i) for i in l] data.append(l) first_half_sum = sum([i[0] for i in data]) second_half_sum = sum([i[1] for i in data]) beauty = mod(first_half_sum,second_half_sum) # prin...
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 f(x): if x < 0: return -x return x n = int(raw_input()) L = 0 R = 0 l = [] r = [] for i in range(n): x, y = map(int, raw_input().split(' ')) L += x R += y l.append(x) r.append(y) cur = f(L - R) ans = -1 for i in range(n): nl = L - l[i] + r[i] nr = R - r[i] + l[i] if f(nl - nr) > cur: ...
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(raw_input()) l,r=[],[] lsum,rsum=0,0 for i in xrange(n): a,b=map(int,raw_input().split()) l.append(a) r.append(b) lsum+=a rsum+=b check=abs(lsum-rsum) ans=0 for i in xrange(n): m=lsum-l[i] q=rsum-r[i] m+=r[i] q+=l[i] if abs(m-q)>check: ans=i+1 check=abs(m-q)...
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()) l=[] for i in range(n): a,b=map(int,input().split()) l.append([a,b]) #print(*l) left=0 right=0 for i in range(n): left+=l[i][0] right+=l[i][1] maxdiff=abs(left-right) a=0 for i in range(n): k=abs((left+l[i][1]-l[i][0])-(right+l[i][0]-l[i][1])) if k>maxdiff: maxdiff=k ...
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; int a[n], b[n]; int L = 0, R = 0, s, p, x, w = 0, i, mx; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; L = L + a[i]; R = R + b[i]; } mx = abs(L - R); for (i = 0; i < n; i++) { s = L + b[i] - a[i]; p = R + 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
n=int(input()) w=[list(map(int,input().split())) for i in range(n)] p,q=0,0 for i in w: p+=i[0] q+=i[1] ans=-1 max1=abs(p-q) for i in range(n): r=abs( (p-w[i][0]+w[i][1]) - (q-w[i][1]+w[i][0]) ) if max1<r: max1=r ans=i print(ans+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
# contest/733/problem/B n = int(input()) LR = [list(map(int, input().split())) for _ in range(n)] suml = sum( (LR[i][0] for i in range(n)) ) sumr = sum( (LR[i][1] for i in range(n)) ) sgn = lambda x: x//abs(x) if x != 0 else 0 resb = [abs(suml - sumr + 2 * (LR[i][1]-LR[i][0])) for i in range(n)] maxind = 0 for i in...
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 i, n, r, l, k, ma, mai, c; long long a[100007]; pair<long long, long long> leg[100007]; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> leg[i].first >> leg[i].second; l += leg[i].first; r += leg[i].second; a[i] = leg[i].first - leg[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.*; import java.util.*; public class A1008 { public static void main(String [] args) /*throws Exception*/ { InputStream inputReader = System.in; OutputStream outputReader = System.out; InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File...
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()) ans = 0 a = [] for i in range(n): x, y = map(int, input().split()) a.append(x-y) s = sum(a) ans = [abs(s)] for i in range(n): ans.append(abs(s - 2*a[i])) print(ans.index(max(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
import java.io.PrintWriter; import java.util.Scanner; public class Aufgabe2 { public Aufgabe2() { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int[] l = new int[n]; int[] r = new int[n]; int beauty = 0; int[] changes = new int[n]; int ls = ...
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.io.*; import java.util.*; public class A implements Runnable { private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; private BufferedReader in; private PrintWriter out; private StringTokenizer tok = new StringTokenizer(""); private void init() throws...
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.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; public class Test { public static void main(String[] args)...
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 helloWorld { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] ar = new int[n]; int sum = 0; for(int i = 0; i < n; i++) sum += ar[i] = in.nextInt() - in.nextInt(); int max = Math.abs(sum); int ans = 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 java.util.Scanner; public class Sample { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int arr[][] = new int[n][2]; long l = 0; long r = 0; for (int i = 0; i < n; i++) { arr[i][0] = s.nextInt(); l+=arr[i][0]; arr[i][1] = s.nextInt(); ...
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()) ans=chk=tmp=0 l=r=0 a,b=[0]*n,[0]*n for i in range(n): x,y=map(int,raw_input().split()) a[i],b[i]=x,y l+=x r+=y ans=abs(l-r) for i in range(n): p=l-a[i]+b[i] q=r-b[i]+a[i] if ans<abs(p-q): ans=abs(p-q) chk=i+1 print chk
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
# coding=utf-8 n=int(raw_input()) minus=[] for i in range(n): l,r=map(int,raw_input().split()) minus.append(l-r) mi=min(minus) mi_index=minus.index(mi)+1 ma=max(minus) ma_index=minus.index(ma)+1 if ma<=0 or mi>=0: print 0 else: print [mi_index,ma_index][abs(sum(minus)-2*mi)<abs(sum(minus)-2*ma)]
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
ta=tb=0 z=[] for i in xrange(input()): l,r=map(int, raw_input().split()) z.append([l,r]) ta+=l tb+=r bt=abs(tb-ta) ci=0 for i in xrange(len(z)): tbt=abs((tb-z[i][1]+z[i][0])-(ta+z[i][1]-z[i][0])) if tbt>bt: bt=tbt ci=i+1 print ci
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()) L=[] R=[] for i in range(n): l,r=[int(x) for x in input().split()] L.append(l) R.append(r) t=sum(L) r=sum(R) v=abs(t-r) d=[] for j in range(n): k= abs(t-L[j]+R[j]-(r-R[j]+L[j])) if k>v: v=k d.append(j) if d==[]: print(0) else: print(d[-1]+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
t=int(input()) d=[] for i in range (t): l,r=map(int,input().split()) d.append(l-r) if min(d)*max(d)>=0: print(0) else : if abs(sum(d)-2*max(d))>abs(sum(d)) and abs(sum(d)-2*max(d))>=abs(sum(d)-2*min(d)) : print (d.index(max(d))+1) elif abs(sum(d)-2*min(d))>abs(sum(d)) and abs(sum(d)-2*max(d))<=abs(sum(d)...
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 numberOfColumns; pair<int, int> column; int indexColumn = -1; int maximum = 0; long totalLeft = 0; long totalRight = 0; vector<pair<int, pair<int, int>>> columns; cin >> numberOfColumns; for (int i = 1; i <= numberOfColumns; ++i) { cin...
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()) k = -1 sl, sr = 0, 0 l = [] for i in range(n): left, right = map(int, input().split()) l.append((left, right)) sl, sr = sl + left, sr + right m = abs(sl - sr) for i in range(n): sl, sr = sl - l[i][0] + l[i][1], sr - l[i][1] + l[i][0] if abs(sl - sr) > m: k = i m = abs(sl - sr) sl, sr = sl...
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; pair<int, int> arr[100100]; int main() { int n, sum1 = 0, sum2 = 0, ans = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> arr[i].first >> arr[i].second; sum1 += arr[i].first; sum2 += arr[i].second; } int diff = abs(sum1 - sum2); int mx = -1; for...
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 sum_left = sum_right = 0 n = int(input()) arr = stdin.readlines() for i in arr: left, right = i.split() sum_left += int(left) sum_right += int(right) res = 0 diff = abs( sum_left - sum_right ) for pos, i in enumerate(arr): left, right = i.split() temp_left = sum_left -...
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> #pragma comment(linker, "/STACK:256000000") using namespace std; const int INF = (int)(1e9 + 1e6); const long long LINF = (long long)(4e18); const double EPS = 1e-13; const int MOD = 1000000007; const int MAXN = 100005; int n; string a; pair<int, int> mas[MAXN]; void solve() { cin >> n; int...
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], r[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int lft = 0; int rgt = 0; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; lft += l[i]; rgt += r[i]; } l[0] = r[0] = 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.util.Scanner; public class Main { private final static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(); int N = n; int totalPositiveDegree = 0; int totalNegativeDegree = 0; int mostPositiveDegr...
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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Parade { public static BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); public static StringTokenizer st; public static void main(String[] args) throw...
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() { ios::sync_with_stdio(0); long long n, R = 0, L = 0; cin >> n; long long l[n], r[n]; for (int x = 0; x < n; x++) { cin >> l[x] >> r[x]; L += l[x]; R += r[x]; } int val = abs(R - L); int ans = 0; for (int x = 0; x < n; x++) { int...
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()) delta = [] L = 0 R = 0 for nn in range(n): l, r = [int(x) for x in input().split()] delta.append(l-r) L += l R += r s = L + R m = 0 mi = 0 for i, d in enumerate(delta): dL = L - d dR = R + d if m < abs(dL-dR): mi = i m = abs(dL-dR) if m < abs(L-R): p...
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() a = [0] * n b = [0] * n l = 0 r = 0 for i in xrange(n): a[i], b[i] = map(int, raw_input().split()) l += a[i] r += b[i] mi = 0 ans = abs(l-r) for i in xrange(n): x = l - a[i] + b[i] y = r - b[i] + a[i] if (ans < abs(x-y)): ans = abs(x-y) mi = i+1 print mi
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()) Q = [] q = 0 for i in range(n): l, r = map(int, input().split()) Q.append([l - r, i + 1]) q += l - r Q. sort() a = abs(q) b = abs(q - 2 * Q[0][0]) c = abs(q - 2 * Q[-1][0]) if a >= b and a>= c: print(0) elif b > c: print(Q[0][1]) else: print(Q[-1][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
/* 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 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
n=int(input()) hold=[] l=0;r=0 for i in range(n): a,b=map(int,input().split()) l+=a;r+=b hold.append([a,b]) beauty=abs(l-r) #print(" Initial beauty=",beauty) new_beauty=0 col=0 for i in range(n): a=hold[i][0] b=hold[i][1] t_l=l-a+b t_r=r-b+a new_beauty=abs(t_l-t_r) #print("At i=",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
a = [] for i in range(int(input())): l, r = map(int, input().split()) a.append(l - r) s = sum(a) v, vi = s, -1 for i, ai in enumerate(a): c = s - 2 * ai if abs(c) > abs(v): v, vi = c, i print(vi + 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
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); 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; const int mx = 100010; int b[3], c[mx], d[3], e[3]; int main() { int n, p, q, k, m; while (cin >> n) { memset(b, 0, sizeof(b)); memset(c, 0, sizeof(c)); memset(d, 0, sizeof(d)); memset(e, 0, sizeof(e)); for (int i = 1; i <= n; i++) { cin >> 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
#include <bits/stdc++.h> using namespace std; int main() { int n; int dis[100005]; int l, r, sum; while (~scanf("%d", &n)) { sum = 0; int flagr = 1, flagl = 1; for (int i = 1; i <= n; i++) { scanf("%d%d", &l, &r); dis[i] = r - l; sum += dis[i]; if (dis[i] > 0) { flagl...
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; cin >> n; int l[n], r[n]; int suml = 0, sumr = 0; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; suml += l[i]; sumr += r[i]; } int bty = abs(suml - sumr); int mbty, key = 0, tbty = bty; 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
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Collections.*; import static java.util.Arrays.*; public class CodeforcesRound378Div2ProblemB { static class Problem { Scanner reader; PrintWriter writer; Problem() { reader = new Scanner(Sy...
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; /** * Created by Piyush on 31-10-2016. */ public class Parade { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[][] arr = new int[n][2]; for (int i = 0; i < n; i++) { arr[i][0] = s.nextInt(...
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 parade { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int C = scan.nextInt(); int[] L = new int[C]; int[] R = new int[C]; int sumL = 0; int sumR = 0; for (int i = 0; i < C; i++) { L[i] = scan.nextInt(); sumL += L[i]; R[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
def parade(): no_columns = int(input()) march_band = [] l_value = 0 r_value = 0 for i in range(no_columns): march_band.append([int(x) for x in input().strip().split(' ')]) l_value += march_band[i][0] r_value += march_band[i][1] max_beauty = abs(l_value - r_value) result = 0 for i in range(no_columns...
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; template <class T> inline void umax(T &a, T b) { if (a < b) a = b; } template <class T> inline void umin(T &a, T b) { if (a > b) a = b; } template <class T> inline T abs(T a) { return a > 0 ? a : -a; } template <class T> inline T gcd(T a, T b) { return __gcd(a, 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; template <class T> inline void amin(T &x, const T &y) { if (y < x) x = y; } template <class T> inline void amax(T &x, const T &y) { if (x < y) x = y; } int N, L[100111], R[100111]; int main() { scanf("%d", &N); for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%d%...
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.InputMismatchException; public class Parade { public static void main(String[] args) { InputReader in = new StreamInputReader(System.in); PrintWriter out = new PrintWriter(System.out); run(in, out); } public static void run(InputReader in, PrintWriter out) { Solver solver...
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() { ios::sync_with_stdio(false); int n, pmax, nmax, pmaxi, nmaxi, L, R, i, l, r, t, b1, b2, b; L = R = pmax = nmax; nmaxi = -99999; pmaxi = nmaxi = -1; cin >> n; for (i = 0; i < n; i++) { cin >> l >> r; L += l; R += r; if (l > 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
import math,sys,re,itertools,pprint,collections ri,rai=lambda:int(input()),lambda:list(map(int, input().split())) n = ri() a = [rai() for i in range(n)] s = 0 for l, r in a: s += l - r res = 0 sres = abs(s) for i in range(n): l, r = a[i] s -= l - r s += r - l if abs(s) > sres: res = 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; int main() { int n; cin >> n; int *a = new int[n]; int *b = new int[n]; int c[100005]; int maxi = -5000, mini = 5000; int res = 0, min_ind, max_ind; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; c[i] = a[i] - b[i]; if (maxi < c[i]) { 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=int(input()) l=[] for i in range(n): l.append(list(map(int,input().split()))) c=0 b=l[0][0]<l[0][1] for i in range (n): if (l[i][0]<l[i][1]) != b : c=1 break if c==0: print(0) else: sl=0;sr=0 for i in range (n): sl+=l[i][0];sr+=l[i][1] d={} ...
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[100005]; int r[100005]; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; } int tot_l = 0, tot_r = 0; for (int i = 0; i < n; i++) { tot_l += l[i]; tot_r += r[i]; } int res =...
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 Main { private static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); while (sc.hasNextInt()) { int n; n = sc.nextInt(); int[][] N = new int[n][2]; for(int i = 0;i<n;i++){ N[i][0] = sc.nextInt(); N[i][1] = sc.nextInt()...
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()) leftminusright=[] for i in xrange(n): l=raw_input().split() leftminusright.append(int(l[0])-int(l[1])) curbestsum=sum(leftminusright) curbest=0 blah=sum(leftminusright) for i in range(1, n+1): test=blah-2*leftminusright[i-1] if abs(test)>abs(curbestsum): curbestsum=test ...
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() l = [] r = [] for _ in range(n): _l, _r = tuple(map(int, raw_input().split())) l.append(_l) r.append(_r) sum_l = sum(l) sum_r = sum(r) M = abs(sum_l-sum_r) i = -1 for j in range(n): dif = l[j]-r[j] _M = abs((sum_l-dif) - (sum_r+dif)) if _M>M: M = _M i = j print 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 sys #file=open("parade.txt",'r') cols=sys.stdin.readline() #cols=file.readline() cols=cols.strip().replace("\n","") cols=int(cols) leftright=[] for i in range(0,cols): a=sys.stdin.readline().strip().replace("\n","") leftright.append(a.split(" ")) maxLoverR=0 loc1=0 maxRoverL=0 loc2=0 count=0 leftTotal=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
n = int(input()) l,r = [],[] for i in range(n): x = list(map(int,input().split())) l.append(x[0]) r.append(x[1]) L,R = sum(l),sum(r) ans = abs(L-R) ind = 0 for i in range(n): x = L-l[i]+r[i] y = R-r[i]+l[i] if ans<abs(x-y): ans = max(ans,abs(x-y)) ind = i+1 print(ind)
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 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 Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc = new Sc...
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
A = [-1 * sum (map (int, ('-' + input()).split())) for _ in range (int(input()))] s, mx, mn = sum (A), max(A), min (A) print (0 if mn > 0 or mx < 0 else A.index(mn) + 1 if s - mn - mx > 0 else A.index(mx) + 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
import java.io.*; import java.util.*; import java.lang.*; public class Rextester{ public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = new Integer(br.readLine()); int beauty = 0; int max = 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
import java.util.*; import java.util.concurrent.*; import java.util.regex.*; public class cc2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); int l[]=new int[t]; int r[]=new int[t]; int left=0,righ...
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()) ns = [] tl, tr = 0, 0 for i in xrange(n): (l, r) = map(int, raw_input().split()) ns.append((l, r)) tl += l tr += r ans = -1 maxi = abs(tl - tr) for i, (l, r) in enumerate(ns): cur = abs(tl - tr + r + r - l - l) if cur > maxi: ans = i maxi = cur 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 pos(int x) { if (x < 0) { return (-x); } return (x); } int l[101000], r[101000]; int main() { int lx = 0, rx = 0, n, i; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d %d", &l[i], &r[i]); lx += l[i]; rx += r[i]; } int maxx = pos(lx ...
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() lines = [] L, R = 0, 0 for x in xrange(n): l, r = map(int, raw_input().split()) L += l R += r lines.append((l,r)) result = { abs(L-R): 0 } for i, line in enumerate(lines): l, r = line krasota = abs(L - l + r - R + r - l) result[krasota] = i + 1 print result[max(result)]
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()) sum = 0 a = [] b = [] for i in range(0, n): c = input() c = c.split() a.append(int(c[0])) b.append(int(c[1])) sum += a[i] - b[i] v = abs(sum) ans = -1 for i in range(0, n): vv = sum - 2*(a[i] - b[i]) vv = abs(vv) if(vv > v): v = vv ans = i print(ans + 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
import java.io.*; import java.util.*; public class TaskB { static InputReader in; static PrintWriter out; public static void main(String[] args) throws FileNotFoundException { InputStream inputStream = System.in; OutputStream outputStream = System.out; in = new InputReader(inputStream); out = 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
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a[n], b[n]; long long int l = 0, r = 0; for (long long int i = 0; i < n; i++) { cin >> a[i] >> b[i]; l += a[i]; r += b[i]; } long long int sum = (abs(l - r)); long long int t = 0; for (long ...
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.*; import java.text.*; import java.lang.*; import java.math.*; public class Main{ static ArrayList a[]=new ArrayList[200001]; static boolean f(char s) { return (s=='a' || s=='e' || s=='i'|| s=='o' || s=='u' || s=='y'); } public void solve () { InputReader in = new InputRea...
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 main() { int n; scanf("%d", &n); int a[n], b[n]; long long int sum = 0, sum1 = 0, count = 0, index = -1; for (int i = 0; i < n; i++) { scanf("%d %d", &a[i], &b[i]); sum += a[i]; sum1 += b[i]; } long long int dif = fabs(sum - sum1); long long int s1, s2; 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
#include <bits/stdc++.h> using namespace std; int l[111111], r[111111]; int main() { int n, maxk = 0, L = 0, R = 0, b = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d", l + i, r + i); L += l[i]; R += r[i]; } b = abs(L - R); for (int i = 0; i < n; i++) if (b < abs(L - R - 2 * ...
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 n; int l[100005], r[100005]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) cin >> l[i] >> r[i]; int ll = 0; int rr = 0; for (int i = 1; i <= n; i++) { ll = ll + l[i]; rr = rr + r[i]; } int maxx = abs(ll - rr); ...
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 isPrime(long long k) { if (k <= 1) { return 0; } if (k == 2) { return 1; } if (k % 2 == 0) { return 0; } long long i = 3; while (i * i <= k) { if (k % i == 0) { return 0; } i += 2; } return 1; } long long binomialCoeff(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
cols = int(raw_input()) lefts, rights = [], [] for col in range(cols): l, r = map(int, raw_input().split()) lefts.append(l) rights.append(r) result = [] for l, r in zip(lefts, rights): result.append(l - r) maxi, max_index, mini, min_index = 0, -1, 1001, -1 for i in range(0, len(result)): if result[i...
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.Scanner; public class Main { @SuppressWarnings("resource") public static void main(String[] args) { Scanner sc = new Scanner(System.in); String sn = sc.nextLine(); int n = Integer.parseInt(sn); String[][] parade = new String[n][2]; int index = 0, beauty =0, li =0, ri = 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 java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Reader.init(System.in); int n = Reader.nextInt() ; int [][] a = new int [n][2] ; int suml = 0 , sumr = 0 , max = 0 , index = 0 ; for (int i=0 ; 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
n = int(input()) l = [] r = [] for i in range(n): a, b = map(int, input().split()) l.append(a); r.append(b); dif = abs(sum(l) - sum(r)) y = -1 sl = sum(l) sr = sum(r) for i in range(n): if abs(sl - l[i] + r[i] - (sr - r[i] + l[i])) > dif: y = i; dif = abs(sl - l[i] + r[i] - (sr - 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.io.IOException; import java.util.Scanner; public class main { public static void main(String[] args) throws IOException { /*BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String firstLine = br.readLine(); int n = Integer.parseInt(firstLine); //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
n=int(input()) l=[] r=[] for i in range(0,n): lr=list(map(int,input().split())) l.append(lr[0]) r.append(lr[1]) diff=[] inital=abs(sum(l)-sum(r)) for i in range(0,n): diff.append(l[i]-r[i]) i1=diff.index(max(diff)) i2=diff.index(min(diff)) l[i1],r[i1]=r[i1],l[i1] ans1=abs(sum(l)-sum(r)) l[i1],r[i1]=r[i1...
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 sys def solve(L, R): n = len(L) d = sum(R) - sum(L) p = max((abs(2*(L[i] - R[i]) + d), i) for i in range(n)) return p[1]+1 if p[0] > abs(d) else 0 n = int(input()) L, R = [], [] for line in sys.stdin: l, r = map(int, line.split()) L.append(l) R.append(r) print(solve(L, R))
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()) l = [] for i in range(n): l.append(list(map(int , input().split()))) sum_arr = [(i[0] - i[-1] )for i in l] Sum = sum(sum_arr) ans =[(abs(Sum) , 0)] ## set as a defualt for i,j in enumerate(sum_arr , 1): ans.append((abs(Sum - 2*j) , i)) print(max(ans)[-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()) LR = [] l, r = 0, 0 for n in range(N): li, ri = map(int, input().split()) l += li r += ri LR += [[li, ri]] cur = abs(l - r) ind = None for i in range(len(LR)): tem = abs(l - LR[i][0] * 2 - r + LR[i][1] * 2) if tem > cur: cur = tem ind = i + 1 if ind == None...
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()) left = [] right = [] for i in range(0, N): (l, r) = input().split(" ") left.append(int(l)) right.append(int(r)) leftSum = sum(left) rightSum = sum(right) sumDiff = leftSum - rightSum absBeauty = abs(leftSum - rightSum) maxBeauty = absBeauty maxColumn = -1 for i in range(0, N): swapB...
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[100000], r[100000]; int main() { long long(n); scanf("%lld", &n); for (long long i = 0; i < (n); ++i) scanf("%d %d", l + i, r + i); long long suml = 0, sumr = 0; for (int i = 0; i < n; ++i) { suml += l[i]; sumr += r[i]; } long long best = abs(sum...
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()) L = 0 R = 0 p = [] for i in range(n): a, b = map(int, input().split(' ')) p.append((a, b)) L += a R += b # print(p) res = abs(L - R) res_i = 0 for i in range(n): if res < abs(L-p[i][0]+p[i][1]-(R-p[i][1]+p[i][0])): res = abs(L-p[i][0]+p[i][1]-(R-p[i][1]+p[i][0])) res...
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; vector<int> v; int mark[1000002]; int qanak(int k) { int u = 0; while (k / 10 != 0) { k = k / 10; u++; } return u; } struct asd { int x, y; }; string s; asd a[1000001]; int i = 0, n, m = 0, l = 0, r = 0, k = 0, z = 0, ans = 0, sx = 0, sy = 0, ex, ey; 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
#!/bin python from sys import stdin def main(): numLines = int(stdin.readline()) #print("Enter %s lines" % numLines) columns = [] columns.append([]) columns.append([]) for i in range(numLines): line = stdin.readline() words = line.split()...
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()) a=[] for i in range(n): x, y=map(int, input().split()) a+=[x-y] ans=0 val=sum(a) mvl=abs(val) for i in range(n): tmp=abs(val-a[i]*2) if mvl<tmp: mvl=tmp 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
import sys fin = sys.stdin fout = sys.stdout results = [] n = int(fin.readline()) columns = [0] * n allL = 0 allR = 0 for i in range(n): l, r = map(int, fin.readline().split()) columns[i] = (l, r) allL += l allR += r results.append((abs(allL - allR), -1)) for i in range(n): tempL = allL tempR =...
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()) columns = [] L, R = 0, 0 for _ in range(n): lr = [int(x) for x in input().split()] l, r = lr[0], lr[1] columns.append((l, r)) L, R = L+l, R+r beauty, ans = abs(L-R), -1 for i, (l, r) in enumerate(columns): L2 = L - l + r R2 = R - r + l if abs(L2-R2) > beauty: beau...
PYTHON3