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
import java.util.*; import static java.lang.System.*; public class B733 { public static void main(String[]args){ Scanner sc = new Scanner(in); int T = sc.nextInt(); int[]left = new int[T]; int[]right = new int[T]; int l,r; l = 0; r = 0; for(int i = 0; i < T; i++) {le...
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
escapeLine=0 leftSum=0 rightSum=0 values=[] totalValue=0 difference=[] try : for line in iter(raw_input,""): if escapeLine>0: leftAndRight = line.split(" ") # leftSum+=int(leftAndRight[0]) # rightSum+=int(leftAndRight[1]) values.append(leftAndRight) genValue=int(leftAndRight[0])-int(leftAndRight[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
t=input() L=0 R=0 d={} T=0 for i in range(t): l,r=map(int,raw_input().split()) L=L+l R=R+r d[i+1]=[l,r] res=[] T=abs(L-R) for i in range(t): res.append(abs((L-d[i+1][0]+d[i+1][1])-(R-d[i+1][1]+d[i+1][0]))) if max(res)>T: print res.index(max(res))+1 else: print 0
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 import math import bisect def solve(A, B): n = len(A) sum_a = sum(A) sum_b = sum(B) max_val = abs(sum_a - sum_b) sol = 0 for i in range(n): tmp_a = sum_a - A[i] + B[i] tmp_b = sum_b - B[i] + A[i] val = abs(tmp_a - tmp_b) if max_val < val: m...
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 argc, const char* argv[]) { int n, maxIndex = 0, maxValu = 0; bool maximed = true; vector<pair<int, int> > data; cin >> n; int l, r; int sumeR = 0, sumeL = 0; for (int i = int(0); i < int(n); i++) { cin >> l >> r; data.push_back(pair<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
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException; import java.io.IOException;import java.io.InputStream;import java.io.PrintStream; import java.io.PrintWriter;import java.security.AccessControlException;import java.util.Arrays; import java.util.Collection;import java.util.Comparat...
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(n); int sumL = 0, sumR = 0; for (int i = 0; i < n; ++i) { cin >> v[i].first >> v[i].second; sumL += v[i].first; sumR += v[i].second; } int prevBeauty = abs(sumL - sumR), beautyIndex = -1; fo...
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.awt.Point; import java.awt.geom.Line2D; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.security.GuardedObject; 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(raw_input()) total = 0 diffs = n * [ None ] for i in range(n): a, b = map(int, raw_input().split()) diffs[i] = a - b total += diffs[i] best_beauty = abs(total) result = 0 for i, diff in enumerate(diffs): beauty = abs(total - 2*diff) if beauty > best_beauty: best_beauty = 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
#include <bits/stdc++.h> int a[100000][2]; int main(void) { int n, i, j, temp, A = 0, B = 0, max = 0, flag = 0; scanf("%d", &n); for (i = 0; i < n; i++) for (j = 0; j < 2; j++) { scanf("%d", &a[i][j]); } for (i = 0; i < n; i++) { A += a[i][0]; B += a[i][1]; } for (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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author llamaoo7 */ public class Main { public static void main(String[] args) { InputStream ...
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, l[100003], r[100003], L, R, beauty; int main() { scanf("%d", &n); L = R = 0; for (int i = 1; i <= n; i++) { scanf("%d%d", &l[i], &r[i]); L += l[i]; R += r[i]; } beauty = abs(L - R); int idx = 0; for (int i = 1; i <= n; i++) { int newL = ...
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()) left = [] right = [] for _t in range(1, n + 1): l, r = map(int, raw_input().split()) left.append(l) right.append(r) sum_left, sum_right = [sum(left), sum(right)] current_value = abs(sum_left - sum_right) pos_max_improv = 0 max_improvement = current_value 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
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.TreeSet; public class tmp { public static void main(String[] Args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] vs = new int[n]; int max = 0; int ind = 0; for (int i = 0; i < n; i++) { vs...
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
/** * Created by ankeet on 11/1/16. */ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B733 { static FastReader in = null; static PrintWriter out = null; public static 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
# Description of the problem can be found at http://codeforces.com/problemset/problem/733/B n = int(input()) t_l = 0 t_r = 0 m_l = 0 m_l_i = 0 m_r = 0 m_r_i = 0 a_n = [[0 for _ in range(2)] for _ in range(n)] for i in range(n): l, r = map(int, input().split()) t_l += l t_r += r a_n[i][0] = l 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
import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; public class Pizza { /** * @param args */ // 12 sec to reach 2nd even static int[]ans; public static void main(...
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 main(): n = int(raw_input()) L, R = zip(*[map(int, raw_input().strip().split()) for i in xrange(n)]) sumL, sumR = sum(L), sum(R) out = abs(sumL - sumR) index = 0 for i, l, r in zip(range(n), L, R): tmp = abs(sumL - sumR - 2 * (l - r)) if tmp > out: out = tmp ...
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, diff = [], [], [] ans = 0 for i in range(n): li, ri = map(int, input().split()) l.append(li) r.append(ri) diff.append(li-ri) lSum = sum(l) rSum = sum(r) currentDiff = abs(lSum - rSum) pos1 = diff.index(max(diff)) pos2 = diff.index(min(diff)) diff1 = abs(lSum - max(diff) - rSum - ...
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() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int, int>> s; for (int i = 1; i <= n; i++) { int a, b; cin >> a >> b; s.push_back(make_pair(a - b, i)); } int s1 = 0, s2 = 0; for (const auto &x : s) { ...
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 dr[] = {0, 1, -1, 0, 1, -1, -1, 1}; int dc[] = {-1, 0, 0, 1, 1, 1, -1, -1}; int l[100020]; int r[100020]; int main() { int sumL = 0, sumR = 0; int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d %d", &l[i], &r[i]); sumL += l[i]; sumR += 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
n=int(input()) l=[] lft,rgt=0,0 for i in range(n): l.append(list(map(int,input().split()))) lft+=l[i][0] rgt+=l[i][1] beauty=abs(lft-rgt) mxbeauty=beauty ans=0 for i in range(n): if(mxbeauty < abs((lft-l[i][0]+l[i][1])-(rgt-l[i][1]+l[i][0]))): mxbeauty=abs((lft-l[i][0]+l[i][1])-(rgt-l[i][1]+l[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() { std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long x = 0, f = 0, j, q = 1, i, n, m, k; while (q--) { j = 0; long long l = 0, r = 0; cin >> n; vector<pair<long long, long long> > v(n); vector<long long> u(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
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) s=0 for j in range(n): k= abs(t-L[j]+R[j]-(r-R[j]+L[j])) if k>v: v=k s=j+1 print(s)
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], r[100005]; int main() { int n, ll = 0, rr = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &l[i], &r[i]); ll += l[i]; rr += r[i]; } int maxx = abs(ll - rr), ans = 0; for (int i = 1; i <= n; i++) { if (abs((ll - 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
#include <bits/stdc++.h> using namespace std; pair<long long, long long> p[1000010]; int main() { long long n, i, suml = 0, sumr = 0; cin >> n; for (i = 0; i < n; i++) { cin >> p[i].first >> p[i].second; suml += p[i].first; sumr += p[i].second; } long long diff = abs(suml - sumr); long long viv ...
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()) heh = [] ans = 0 LminusR = 0 for i in range(n): l, r = map(int, input().split()) LminusR += l LminusR -= r heh.append(2 * (r - l)) kok = abs(LminusR) for e in range(n): i = heh[e] if abs(LminusR + i) > kok: kok = abs(LminusR + i) ans = e + 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; int n, l[112345], r[112345], total, ans; int main(int argc, char const *argv[]) { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &l[i], &r[i]); total += l[i] - r[i]; } for (int i = 1; i <= n; i++) { if (abs(total - 2 * l[i] + 2 * 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; int main() { long long int n, i, j, k, L = 0, R = 0, maxk, index, t; cin >> n; int li[n], ri[n]; for (i = 0; i < n; i++) { cin >> li[i] >> ri[i]; L += li[i]; R += ri[i]; } t = fabs(L - R); maxk = fabs(L - R); for (i = 0; i < n; i++) { k = fab...
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 = [] B = [] Max1 = 0 Max2 = 0 c = 0 d = 0 Sum1 = 0 Sum2 = 0 for i in range(0,n): a,b = input().split() if int(a)-int(b)>Max1: Max1 = int(a)-int(b) c = i+1 if int(b)-int(a)>Max2: Max2 = int(b)-int(a) d = i+1 Sum1 = Sum1 + int(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
nCol = input() cols = [] for i in xrange(nCol): cols.append(map(int, raw_input().split())) leftTotal = 0 rightTotal = 0 for c in xrange(nCol): leftTotal += cols[c][0] rightTotal += cols[c][1] maxBeauty = abs(leftTotal - rightTotal) maxBeautyIndex = 0 for i in xrange(nCol): beauty = abs((leftTotal - cols[i][0] ...
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()) parad=[list(map(int,input().split())) for i in range(n)] R=0 L=0 s=0 for i in range(n): R+=parad[i][1] L+=parad[i][0] k=abs(L-R) max=abs(L-R) for i in range(n): k=abs((L-parad[i][0]+parad[i][1])-(R-parad[i][1]+parad[i][0])) if k>max: max=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
n = int(input()) a, b = [], [] for i in range(n): x, y = map(int, input().split()) a.append(x) b.append(y) sa = sum(a) sb = sum(b) d = abs(sa - sb) i = 0 for j in range(n): _d = abs((sa + b[j] - a[j]) - (sb + a[j] - b[j])) if _d > d: d = _d i = j + 1 print(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
numbers = [] L = 0 R = 0 def getMaxBeauty(): global numbers, L, R maximo = abs(L - R) column = 0 flag = False for i in range(0, n): dif = numbers[i][1] - numbers[i][0] beauty = abs((L + dif) - (R - dif)) if beauty > maximo: maximo = beauty ...
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 Maths { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); ...
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 = [] l = r = 0 for i in range(n): a.append(list(map(int, input().split()))) l+= a[-1][0] r+= a[-1][1] mi = abs(l - r) #print(l, r) res = 0 L, R = l, r for i in range(n): l-= a[i][0] r+= a[i][0] r-= a[i][1] l+= a[i][1] #print(l, r) if abs(l - r) > mi: res = i + 1 mi = abs(l - r) l = 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
def get_int(): return map(int, input().split()) n = int(input()) L = R = 0 a = [] for i in range(n): x, y = get_int() L += x R += y a.append((x-y, i)) m = abs(L-R) x = 0 for i in range(n): if abs(L - 2*a[i][0] - R) > m: m = abs(L - 2*a[i][0] - R) x = a[i][1] + 1 print(x)
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.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import javax.swing.plaf.basic.BasicInternalFrameTitlePane.MaximizeAction; import static java.lang.Math.*; public class B implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""...
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) left=sum(l_lst) right=sum(r_lst) c_beauty=abs(left-right) index=0 for i in range(n): lol=abs((left-l_lst[i]+r_lst[i])-(right+l_lst[i]-r_lst[i])) if lol >c_beauty: c_beauty=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
n = input() l, r = 0, 0 ll = [] rr = [] for i in xrange(n): li, ri = map(int, raw_input().split()) ll.append(li) rr.append(ri) l = sum(ll) r = sum(rr) ans = -1 maxi = abs(l-r) for i in xrange(n): flip = abs((l-ll[i]+rr[i])-(r-rr[i]+ll[i])) if maxi < flip: maxi = flip ans = i print a...
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 Main { public static void main(String[] args) throws IOException { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); int test_cases = 1; Solver s = new Solver(); for (int i = test_cases; 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
__author__ = 'Think' n=int(input()) total=0 diffmax=-500 maxi=-1 mini=-1 diffmin=500 for i in range(n): l, r=[int(i) for i in input().split()] diff=l-r if diff>diffmax: maxi=i diffmax=diff if diff<diffmin: mini=i diffmin=diff total+=diff if abs(total-2*diffmax)>abs(total-2*diffmin): if abs(total-2*diffma...
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(raw_input()) l = 0 r = 0 #a = [] c = [] for _ in xrange(n): b = map(int,raw_input().split()) #a.append(b) l +=b[0] r +=b[1] c.append(b[0]-b[1]) #print l,r #print a maxv = abs(l-r) d = -1 for i in xrange(n): if abs(l-c[i]-r-c[i])>maxv: d = i maxv = abs(l-c[i]-r-c[i]) print...
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()) pairs = [] L = 0 R = 0 for i in range(n): pair = input().split(' ') L += int(pair[0]) R += int(pair[1]) pairs.append((int(pair[0]), int(pair[1]), (i+1))) pairs.sort(key = lambda x: abs(L - R + 2*(x[1] - x[0]))) if abs(L - R + 2*(pairs[-1][1] - pairs[-1][0])) <= abs(L - R): print(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()) data = [list(map(int, input().split())) for i in range(n)] data = list(map(lambda x: x[0]-x[1], data)) order = [sum(data)] order.extend(map(lambda x: order[0]-2*x, data)) print(order.index(max(order, key=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.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class R378D2P2 { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(bf.readLine()); int[] leftCoun...
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 l[100000], r[100000]; int main() { int n, sum_l = 0, sum_r = 0, ans = 0; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d%d", &l[i], &r[i]); sum_l += l[i]; sum_r += r[i]; } for (int i = 0, max_l = sum_l, max_r = sum_r; i < n; ++i) if (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
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); int L[n], R[n]; int sl = 0, sr = 0; for (int i = 0; i < n; i++) { scanf("%d %d", &L[i], &R[i]); sl += L[i]; sr += R[i]; } int diff = abs(sl - sr); int ans = 0; for (int i = 0; i < n; i++) { sl -= 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; pair<int, int> a[100001]; int main() { int ind = -1; int L = 0, R = 0; int n; cin >> n; for (int i = 1; i <= n; ++i) { int x, y; cin >> x >> y; a[i] = make_pair(x, y); L += x; R += y; } int ans = abs(L - R); 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
N = int(raw_input()) L = [] R = [] for i in xrange(N): (l, r) = map(int, raw_input().split(' ')) L.append(l) R.append(r) sumL = sum(L) sumR = sum(R) best = abs(sumL - sumR) best_idx = 0 for i in xrange(N): if abs((sumL - L[i] + R[i]) - (sumR - R[i] + L[i])) > best: best_idx = i+1 best...
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 = [0] * n r = [0] * n L = R = 0 for i in range(n): l[i], r[i] = map(int, input().split()) L += l[i] R += r[i] m = abs(L - R) j = -1 for i in range(n): k = abs(L - 2 * l[i] + 2 * r[i] - R) if k > m: m = k j = i print(j + 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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin....
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 final class parade { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); public static void main(String args[]) throws Exception { 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(raw_input()) l = [] r = [] for i in xrange(n): a,b = map(int,raw_input().split()) l.append(a) r.append(b) l1 = sum(l) r1 = sum(r) beauty = abs(l1 - r1) ans = 0 for i in xrange(n): l2 = l1 - l[i] + r[i] r2 = r1 - r[i] + l[i] if((l2 > 0)and(r2>0)): newb = abs(l2 - r2) ...
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
l = [0] + [sum(map(int, ('-' + input()).split())) for _ in range(int(input()))] s, a, b = sum(l), min(l), max(l) print(l.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
import math,sys,bisect,heapq from collections import defaultdict,Counter,deque from itertools import groupby,accumulate #sys.setrecursionlimit(200000000) input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__ ilele = lambda: map(int,input().split()) alele = lambda: list(map(int, input().split())) def 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()) l, r = [], [] L, R = 0, 0 for i in range(n) : x, y = map(int, input().split()) l.append(x) r.append(y) L, R = L + x, R + y ans, newL, newR = 0, L, R for i, (x, y) in enumerate(zip(l, r)) : if abs(L - x + y - (R - y + x)) > abs(newL - newR) : newL = L - x + y newR = R - y + x; 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()) mass=[] for i in range(n): a,b=map(int, input().split()) mass.append(a-b) minm=min(mass) if minm>0: minm=0 maxm=max(mass) if maxm<0: maxm=0 summ=sum(mass) res=-1 if abs(summ-maxm-maxm)>abs(summ) and abs(summ-minm-minm)<abs(summ-maxm-maxm): summ-=2*maxm res=mass.index(maxm) elif ab...
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().strip()) ll = [] l = 0 r = 0 for i in range(n): u = list(map(int,input().split())) ll.append(u[0] - u[1]) l += u[0] r += u[1] maxx = max(ll) minn = min(ll) LLL = abs(l - r - 2 * minn) RRR = abs(r + 2 * maxx - l) if LLL >= RRR and LLL > abs(l - r): for i in range(n): if ll[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.*; import java.awt.geom.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) { long startTime = System.nanoTime(); int n=in.nextInt(); int L=0; int R=0; int ans=0; int [] ll = new int[n]; int [] rr = new int[n]; for(in...
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.awt.Point; import java.io.*; import java.util.*; public class Main implements Runnable { int maxn = (int)1e5+111; int mod = (int)1e9+7; int inf = (int)1e9; int n,m,k; Point a[] = new Point[maxn]; void solve() throws Exception { n = in.nextInt(); int sumLeft = 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(input()) ls = [] rs = [] for i in range(n): l, r = [int(x) for x in input().split()] ls.append(l) rs.append(r) lss = sum(ls) rss = sum(rs) best = abs(lss - rss) ans = None for i in range(n): lss1 = lss - ls[i] + rs[i] rss1 = rss - rs[i] + ls[i] if abs(lss1 - rss1) > best: best = abs(lss1 - rss1) 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; using ll = long long; using pii = pair<int, int>; using pli = pair<ll, int>; const int INF = 0x3f3f3f3f, N = 2e5 + 5; const ll LINF = 1e18 + 5; int n, L[N], R[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> 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
r=lambda:map(int,raw_input().split()) n=input() s=[] S=[] m=0 M=0 for i in range(n): L,R=r() s.append(R-L) S.append(R-L) if s[-1] > 0: M+=s[-1] else: m-=s[-1] S.sort() m=abs(sum(S[:-1])-S[-1]) M=abs(sum(S[1:])-S[0]) R=abs(sum(S)) #print S, m,M,R if M >= m and M > R: pri...
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.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int max = 0; int l = 0, r = 0; int h[][] = new int[n][2]; for (int i = 0; i < n; i++) { l += h[i][0] = in.nextInt(); r += h[i][1] = in.nextInt(); } max ...
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 CF { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); int n = Integer.parseInt(s); int L = 0, R = 0; int ll[] = new int[n]; int rr[] = 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
var n = +readline(); var arr = [], l = 0, r = 0; for (var i = 0; i < n; i++) { var input = readline().split(' ').map(Number); l += input[0]; r += input[1]; arr.push(2 * (input[0] - input[1])) } var max = Math.abs(l - r), k = 0; arr.forEach((el, i) => { var curr_val = Math.abs(l - r - el); if (ma...
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()) m=[] for i in range(n): g=list(map(int,input().split())) m.append(g) l=0 r=0 for i in range(n): l+=m[i][0] r+=m[i][1] beauty=abs(l-r) ans=0 for i in range(n): x=l-m[i][0]+m[i][1] y=r-m[i][1]+m[i][0] a=abs(x-y) if a>beauty: beauty=a 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
n = input() a = [] d = [] b = 0 for i in range(n): a.extend(map(int, raw_input().split())) d.append(a[2 * i + 1] - a[2 * i]) b += d[i] dmin = min(d) dmax = max(d) bmin = abs(b - 2 * dmin) bmax = abs(b - 2 * dmax) b = abs(b) if b >= bmax and b >= bmin: print('0') elif bmax >= b and bmax >= bmin: 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
#include <bits/stdc++.h> int L[100000]; int R[100000]; int SumL, SumR; int main() { int N, maxAns = 0, maxIdx = -1; scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%d %d", &L[i], &R[i]); SumL += L[i]; SumR += R[i]; } maxAns = abs(SumL - SumR); for (int i = 0; i < N; ++i) { int lprime =...
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 n = int(stdin.readline()) a = [0] b = [0] for i in xrange(n): x,y = map(int,stdin.readline().split()) a.append(x) b.append(y) ans = 0 u = sum(a) v = sum(b) ma= u-v if ma< 0: ma= 0-ma for i in xrange(1,n+1): x = a[i];y = b[i] xx = u - x + y yy = v - y + x cur = xx - yy if cur < 0: 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(input()) columns = [list(map(int, input().split())) for i in range(n)] difference_of_columns = [columns[i][0] - columns[i][1] for i in range(n)] min_beauty = max_beauty = difference_of_columns[0] min_beauty_index = max_beauty_index = 0 for i in range(n): if difference_of_columns[i] > max_beauty: ...
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.*; import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; /*```````````````````````````````````````````````````````````````````````````````````...
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; long long exp(long long b, long long e) { if (b == 1 || e == 0) return 1; if (e == 1) return b % 1000000007; if (e == 2) return (b * b) % 1000000007; return ((e % 2 == 0) ? exp(exp(b, e / 2), 2) % 1000000007 : (b * (exp(exp(b, e / 2), 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; const int MAXN = 100500; int n, l[MAXN], r[MAXN], L, R, maxv, maxi; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> l[i] >> r[i], L += l[i], R += r[i]; maxv = abs(R - L); for (int i = 0; i < n; i++) { int nw = abs((L - l[i] + r[i]) - (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()) l,r,sl,sr,mx,a = [],[],0,0,0,0 for i in range(n): l1,r1 = map(int,input().split()) l.append(l1) r.append(r1) sl+=l1 sr+=r1 mx = abs(sl-sr) for i in range(n): sl = abs(sl-l[i]+r[i]) sr = abs(sr-r[i]+l[i]) t1 = abs(sl-sr) if t1>mx: mx = t1 a = 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
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { private void solve() throws Exception{ int n = ri(); int[] l = new int[n], r = new int[n]; int lsum = 0, rsum = 0; for (int i = 0; i < n; i++){ int[] k =ria(2); l[i] = k...
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 n, m, i, j, k = 0, l = 0, t = 0, c, x = 0, y = 0; cin >> n; long long a[n + 5], b[n + 5]; for (i = 1; i <= n; i++) { cin >> a[i] >> b[i]; x += a[i]; y += b[i]; } long long mx = abs(x - y); for (i = 1; i <= n; i++) { t = 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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Created by constanzafierro on 31-10-16. */ public class B { static int n, columns[]; public static void main(String[] args) throws IOException { BufferedReader br = 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
# your code goes here n=int(input('')) a=[] b=[] l=0 r=0 z=-1 #print("pp") for i in range(n): #print("s") a.append([int(j) for j in input().split()]) l=l+a[i][0] r=r+a[i][1] #print("k") b.append(a[i][0]-a[i][1]) p=max(l,r) #print("p") for i in range(len(b)): if b[i]<0: if l+abs(b[i])>p: p=l+abs(b[i]) z=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.*; public class B733codeforces { public static int abs(int a){ if(a<0){ return -a; } return a; } public static void main(String args []){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n]; int[] r = new int[n]; int suml=0,sumr=0; fo...
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 l[N]; int r[N]; int suml = 0; int sumr = 0; int beauty = 0; for (int i = 0; i < N; i++) { cin >> l[i] >> r[i]; suml = suml + l[i]; sumr = sumr + r[i]; } beauty = abs(suml - sumr); int ll, rr; int point = ...
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
l=[0]+[eval("-".join(input().split()))for _ in range(int(input()))];print(l.index([max(l),min(l)][max(l)+min(l)<sum(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
import math n=int(input()) mylist=[] for i in range(n): mylist.append([int(j) for j in input().split()]) mL=0 mR=0 for i in range(len(mylist)): mL+=mylist[i][0] mR+=mylist[i][1] beauty= math.floor(math.fabs(mL-mR)) s=0 for i in range(len(mylist)): L=mL R=mR L-=mylist[i][0] R-=mylist[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
#include <bits/stdc++.h> using namespace std; int main() { int n, l[100001], r[100001]; cin >> n; long long int maxl = 0, maxr = 0; int diff = 0, ind = -1; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; maxl += l[i]; maxr += r[i]; } for (int a = 0; a < n; a++) { if ((l[a] - r[a] > diff...
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 scanner = new Scanner(System.in); int col = scanner.nextInt(); int left[] = new int[col]; int right[] = new int[col]; int initialLeftSum = 0; int initialRightSum = 0; for(int i = 0; i < col; ...
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 B { @SuppressWarnings("resource") public static void main(String[] args) { Scanner sc = new Scanner(System.in); int nb = sc.nextInt(); int L = 0, R = 0, indiceMax = 0; int[][] tab = new int[nb][2]; for (int i = 0; i < nb; i++) { int l = sc.nextInt(); int r = 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
#include <bits/stdc++.h> using namespace std; struct col { int index; int diff; }; bool comp(col a, col b) { return a.diff < b.diff; } int main() { int n; scanf("%d", &n); col in[n]; int l, r; int cnt = 0; for (int i = 0; i < n; ++i) { scanf("%d %d", &l, &r); in[i].index = i + 1; in[i].diff ...
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.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOExceptio...
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()) sl = 0 sr = 0 columns = [] for i in range(n): columns.append(list(map(int, input().split()))) sl += columns[-1][0] sr += columns[-1][1] beauty = abs(sl - sr) new_beauty = beauty index = -1 for i, j in enumerate(columns): new_sl = sl - j[0] new_sr = sr - j[1] new_sl += j[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()) sol = [] L = 0 R = 0 for i in range(n): l,r = map(int,input().split()) col = [l,r] L+=l R+=r sol.append(col) max = abs(L-R) ans = 0 for i in range(n): temp_l = L-sol[i][0]+sol[i][1] temp_r = R-sol[i][1]+sol[i][0] if abs(temp_l-temp_r) > max: max = abs(temp_l-t...
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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Parad { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int colonn = Integer.parseInt(reader.readLine(...
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 TaskB { static InputReader in; static PrintWriter out; public static void main(String[] args) throws FileNotFoundException { InputStream inputStream = System.in; //FileInputStream inputStream = new FileInputStream("input.txt"); OutputStream outputStrea...
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=[] i=0 ma=0 t=-1 s1=0 s2=0 for i in range(n): l.append(0) r.append(0) l[i],r[i]=map(int, input().split()) for i in range(n): s1+=l[i] s2+=r[i] ma=abs(s1-s2) for i in range(n): if abs((s1-l[i]+r[i])-(s2-r[i]+l[i]))>ma: ma=abs((s1-l[i]+r[i])-(s2-r[i]+l[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
chislo = int(input()) mas = [ ] Left = 0 Right = 0 Index = 0 for i in range(chislo): a = list(map(int,input().split())) Left += a[0] Right += a[1] mas.append(a) Max = abs(Left - Right) for razi in range(len(mas)): if abs((Left - mas[razi][0] + mas[razi][1])-(Right-mas[razi][1]+mas[razi][0])) >M...
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
// CodeForces Round #715 B // graphs, dijkstra algorithm, not solved import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.PriorityQueue; public class Parade { int n; int []la; ...
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 long long ar[100001], br[100001]; int long long m1 = 0, m2 = 0, n, mx, mn, pos = -1; cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i] >> br[i]; m1 += ar[i]; m2 += br[i]; } mx = max(m1, m2); mn = min(m1, m2); int long long v =...
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 maxi = 100010; int main() { int n; cin >> n; int left, right; left = right = 0; int arr[maxi]; int brr[maxi]; for (int i = 0; i < n; i++) { cin >> arr[i] >> brr[i]; left += arr[i]; right += brr[i]; } int diff = abs(left - right); 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(input()) sum_ls=[] diff=0 res=0 rec=0 for i in range(n): tmp=input() tmp=tmp.split(' ') sum_ls.append(int(tmp[0])-int(tmp[1])) diff+=sum_ls[i] for p in range(len(sum_ls)): if res<abs(diff-sum_ls[p]*2) and abs(diff-sum_ls[p]*2)>abs(diff): res=abs(diff-sum_ls[p]*2) rec=p+1 if rec...
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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ...
JAVA