prompt
string
response
string
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import static java.lang.Math.abs; import java.util.*; public class Codeforces { public static void main(String[] a){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int left[]=new int[n]; int right[]=new int[n]; long sumLeft=0; long sumRight=0; int maxdif...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; /** * Created by Askar on 07.06.2017. */ public class task1 { public static void main (String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nex...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
a=[] for i in range(int(input())): a.append(list(map(int,input().split()))) k=[0,0] for j in a: k[0]+=j[0] k[1]+=j[1] k1=abs(k[0]-k[1]) maxi=-1 maxd=k1 for l in range(len(a)): a[l][0],a[l][1]=a[l][1],a[l][0] k2=[k[0]-a[l][1]+a[l][0],k[1]-a[l][0]+a[l][1]] k1=abs(k2[0]-k2[1]) if k1>maxd: ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int a[n][2]; int l = 0, r = 0; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; l += a[i][0]; r += a[i][1]; } int ans = abs(l - r); int i...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()); dl = []; ans = L = R = 0; for i in range(n): l,r = map(int, input().split()); L+=l; R+=r; dl+=[[l,r]]; ans = abs(L-R); index=-1 for i in range(n): ts=abs(L-R+2*(-dl[i][0]+dl[i][1])); if ts>ans: ans=ts; index=i; print(index+1);
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
# coding=utf-8 __author__ = 'Alexander' n = input() n = int(n) l = [] r = [] L0 = 0 R0 = 0 for i in range(n): s = input() lt, rt = map(int, s.split()) l.append(lt) r.append(rt) L0 += lt R0 += rt B0 = abs(L0-R0) # print(L0, R0, B0) BN = B0 N = 0 for i in range(n): L = L0 - l[i] + r[i] ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) cols = [] for _ in range(n): l, r = map(int, input().split()) cols.append((l,r)) sum_l = sum((i[0] for i in cols)) sum_r = sum((i[1] for i in cols)) dif_col = -1 beaut = abs(sum_l - sum_r) for idx,col in enumerate(cols): b = abs((sum_l - col[0] + col[1]) - (sum_r - col[1] + col[0])) if ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#!/usr/bin/env python3 n = int(input()) diff = [] for i in range(n): l, r = map(int, input().split()) diff.append(l-r) b = sum(diff) i = max(range(n), key=lambda x: abs(b-2*diff[x])) if abs(b-2*diff[i]) > abs(b): print(i+1) else: print(0)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; long long n, mx, ans = -1, L, R, l_new, r_new, cnt; int main() { cin >> n; vector<long long> l(n), r(n); for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } mx = abs(L - R); for (int i = 0; i < n; i++) { l_new = L - l[i] + ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.Scanner; /** * * @author Gilbert */ public class Parade { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int li[] = new int[n]; int ri[] = new int[n]; int L = 0,R = 0; int min = Integer.MAX_...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, long long> a, pair<int, long long> b) { return a.second > b.second; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, i, L = 0, R = 0; cin >> n; long long l[n], r[n]; map<long long, int, greater<long long> >...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#!/usr/bin/env python3 if __name__ == '__main__': n = int(input()) tl = 0 tr = 0 cols = [[0, 0]] for _ in range(n): l, r = map(int, input().split()) tl += l tr += r cols.append((l, r)) beauty = abs(tl - tr) best = 0 for i in range(1, n+1): ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(raw_input()) suml = 0 sumr = 0 le = [] ri = [] for i in range(n): l, r = list(map(int, raw_input().split())) le.append(l) ri.append(r) sumr += r suml += l maxx = abs(sumr - suml) maxi = -1 for i in range(n): if (abs(sumr - ri[i] + le[i] - (suml - le[i] + ri[i])) > maxx): maxx = a...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
/* LANG: JAVA TASK: combo */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Random; public class combo { public static void main(String[] args) throws Exception { BufferedReader bR = new BufferedReader(new InputStreamReader(System.in)); int columns = Integer.parseInt(bR.readL...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) a = [] r = 0 l = 0 for i in range(n): x,y = [int(j) for j in input().split()] l+=x r+=y a.append([x,y]) mk = abs(l-r) ind = 0 for i in range(n): k = abs((l-a[i][0]+a[i][1])-(r-a[i][1]+a[i][0])) if k > mk: mk = k ind = i+1 print(ind)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> l(n), r(n); int ret = 0, mx = 0; int L = 0, R = 0; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } mx = abs(L - ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) c=-1 d=-1 sum1=0 sum2=0 str2 = []*(n+1) str1 = []*(n+1) for i in range(n): [a,b] = input().split(' ') a = int(a) sum1=sum1+a b = int(b) sum2=sum2+b str1.append(a) str2.append(b) num = abs(sum1-sum2) for i in range(n): if num<abs((sum1-str1[i]+str2[i])-(sum2-str2[i]+st...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
k = int(raw_input()) lh = [] rh = [] for _ in range(k): l, r = map(int, raw_input().split()) lh.append(l) rh.append(r) ls = sum(lh) rs = sum(rh) ob = abs(ls - rs) b = 0 bi = 0 for i in range(k): t = abs(ls - lh[i] + rh[i] - (rs - rh[i] + lh[i])) if t > b: b = t bi = i print bi + 1 if...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(raw_input()) sl = sr = 0 all = [] for _ in xrange(n): l, r = map(int, raw_input().split()) sl += l sr += r all.append([l, r]) b = abs(sl - sr) ret = 0 for i in xrange(n): l, r = all[i] if abs(sl - l + r - (sr - r + l)) > b: ret = i + 1 b = abs(sl - l + r - (sr - r + l)) p...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main(void) { int n = 0; int i; cin >> n; int soldiers[n][2]; int absLR[n]; int sumL = 0, sumR = 0; int maxabs = 0; int index = 0; for (i = 0; i < n; i++) { cin >> soldiers[i][0]; cin >> soldiers[i][1]; sumL += soldiers[i][0]; sumR += so...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int L[100100], R[100100]; int main(void) { int n; while (~scanf("%d", &n)) { for (int i = 0; i < n; i++) scanf("%d%d", &L[i], &R[i]); int sumL = 0, sumR = 0; for (int i = 0; i < n; i++) sumL += L[i], sumR += R[i]; int mn = abs(sumL - sumR), ans = -1; ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) sum_l = 0 sum_r = 0 a = [] for i in range(n): l, r = map(int, input().split()) sum_l += l sum_r += r a.append([l, r]) k = abs(sum_l - sum_r) ind = 0 for i in range(n): n_l = sum_l n_r = sum_r x = abs((n_l - a[i][0] + a[i][1]) - (n_r - a[i][1] + a[i][0])) if x > k: ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
# You lost the game. n = int(input()) C = [list(map(int, input().split())) for i in range(n)] L = sum([C[i][0] for i in range(n)]) R = sum([C[i][1] for i in range(n)]) if 1: ml = 0 mr = 0 ind1 = -1 ind2 = -1 for i in range(n): if C[i][1]-C[i][0] > ml: ml = C[i][1]-C[i][0] ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) l = [] r = [] L = 0 R = 0 for i in range(n): a, b = map(int, input().split()) L += a R += b l.append(a) r.append(b) dif = L - R mind = dif ans = 0 for i in range(n): tmp = dif + 2 * (r[i] - l[i]) if abs(tmp) > abs(mind): mind = tmp ans = i+1 print(ans)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; long long n, l, r, s, m, c, d[110000]; int main() { cin >> n; for (long long i = 0; i < n; i++) { cin >> l >> r; d[i] = l - r; s = s + l - r; } m = s; for (long long i = 0; i < n; i++) { if (abs(-2 * d[i] + s) > abs(m)) { c = i + 1; m =...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 3; int left1[N] = {0}; int right1[N] = {0}; int n; int main(void) { scanf("%d", &n); int left_sum = 0; int right_sum = 0; int a, b; for (int i = 1; i <= n; i++) { scanf("%d", left1 + i); scanf("%d", right1 + i); left_sum += left1[i]...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
# Created by Daniil Kozhanov. All rights reserved. # october 2016 # n = int(input()) sl = [] sr = [] index = 0 for i in range(n): l, r = list(map(int, input().split())) sl.append(l) sr.append(r) NICE = sum(sl) - sum(sr) mnice = abs(NICE) if NICE > 0: for j in range(n): e = abs(NIC...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) res = [0] for i in range(n): l, r = map(int, input().split()) res.append(l-r) ma = max(res) mi = min(res) s = sum(res) if ma+mi<s: print(res.index(mi)) else: print(res.index(ma))
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) D = [0] * n for i in range(n): l, r = map(int, input().split()) D[i] = l - r beauty, min_d, max_d = sum(D), min(D), max(D) print(max((beauty, 0), (beauty - 2 * min_d, D.index(min_d) + 1), (beauty - 2 * max_d, D.index(max_d) + 1), key = lambda data: abs(data[0]))...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<int, int>> columns; int n, l, r, ltot = 0, rtot = 0; pair<int, int> best; cin >> n; for (int i = 0; i != n; ++i) { cin >> l >> r; ltot += l; rtot += r; columns.push_back(make_pair(l, r)); } best = make_pair(0, abs(ltot ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, j, k, xa, ya, ox, oy, od; xa = 0; ya = 0; cin >> n; long long int a[n], b[n]; j = -1; for (i = 0; i < n; i++) { cin >> a[i] >> b[i]; xa = xa + a[i]; ya = ya + b[i]; } od = abs(xa - ya); for (i = 0; i < n; i++)...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; long long arr[100010], brr[100010]; int main() { long long n, i, res, a, ls, rs, ma; while (scanf("%lld", &n) != EOF) { ls = 0; rs = 0; for (i = 0; i < n; i++) { scanf("%lld", &arr[i]); ls += arr[i]; scanf("%lld", &brr[i]); rs += brr[...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n=[sum(map(int,('-'+input()).split())) for i in range(int(input()))] s,a,b=sum(n),min(n),max(n) if abs(s+a*(-2))>abs(s) and abs(s+a*(-2))>abs(s+b*(-2)) :print(n.index(a)+1) elif abs(s+b*(-2))>abs(s):print(n.index(b)+1) else:print(0)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.Scanner; public class R733B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(), ans=0, dl=0, dr=0, pl=0, pr=0, d=0, max; for(int i=1; i<=n; i++) { int l=in.nextInt(), r=in.nextInt(); d+=l-r; ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) a = [0] * n l = 0 r = 0 for i in range(n): a[i] = list(map(int, input().split())) l += a[i][0] r += a[i][1] best = abs(l - r) ans = 0 for i in range(n): new = abs((l - a[i][0] + a[i][1]) - (r - a[i][1] + a[i][0])) if new > best: best = new ans = i + 1 print(ans)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) L, R = 0, 0 a = [] for i in range(n): li, ri = map(int, input().split()) a.append([li, ri]) L += li R += ri ans = abs(L - R) ansi = 0 for i in range(n): l1 = L - a[i][0] + a[i][1] r1 = R - a[i][1] + a[i][0] if abs(l1 - r1) > ans: ans = abs(l1 - r1) ansi = i +...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; const int MAX = 1100100; long long N, l, r; long long L[MAX], R[MAX], d, sol; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N; for (int I = 0; I < N; I++) { cin >> L[I] >> R[I]; l += L[I]; r += R[I]; } d = abs(l - r); for (int I = 0...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import os LOCAL_PC = 'n1amr' in os.path.expanduser('~') def solve(input, print): n = int(input()) pos = neg = 0 A = [0] * n for i in range(n): l, r = map(int, input().split()) A[i] = df = l - r if df < 0: neg += df else: pos += df beauty = a...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.*; public class B_378{ public static void main(String[] args){ Scanner sc =new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; for(int i=0; i<n;i++){ int l=sc.nextInt(); int r=sc.nextInt(); a[i]=l-r; } int min=0; int max=0; int pos=0; ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.Scanner; public class m8 { public static void main(String args[]) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int l[]=new int[n+1]; int r[]=new int[n+1]; int ls=0; int rs=0; for(int i=1;i<=n;i++) { l[i]=s.nextInt(); r[i]=s.nextInt(); } for(int i=1;i<=n;i++) { ls+=l[i]; rs...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
l=[] for i in range(input()): a,b=map(int,raw_input().split()) l.append(a-b) s=sum(l) p,q=max(l),min(l) if abs(s)>abs(s-2*p): if abs(s)>abs(s-2*q): print 0 exit() else: print l.index(q)+1 exit() if abs(s-2*p)>abs(s-2*q): print l.index(p)+1 exit() print l.index(q)+1
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { int ans, n, l[100005], r[100005], left = 0, right = 0, i, c1, c2, in = 0; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d %d", &l[i], &r[i]), left += l[i], right += r[i]; ans = abs(left - right); for (i = 0; i < n; i++) { c1 = left; c2 ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { static StringBuilder a = new StringBuilder()...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) a = [] l,r = 0,0 for i in range(n): x,y= map(int,input().split()) l+=x r+=y a.append([x,y]) x = abs(l-r) ind = 0 for i in range(n): if abs(l-a[i][0]+a[i][1]-r+a[i][1]-a[i][0]) > x: x = abs(l-a[i][0]+a[i][1]-r+a[i][1]-a[i][0]) #print(x) ind = i+1 print(ind)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(raw_input()) total = 0 diffs = [] for i in xrange(n): x,y = map(int,raw_input().split()) diffs.append(x-y) total += (x-y) ans = 0 #print total maxtotal = total for i in xrange(n): cur = diffs[i] newtotal = (total - 2*cur) #print newtotal if abs(newtotal) > abs(maxtotal): ans = i+1 maxtotal = newt...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = input() col = [] lsum = 0 rsum = 0 for i in range(n): (l, r) = raw_input().split() (l, r) = (int(l), int(r)) col.append((l,r)) lsum += l rsum += r res = abs(lsum - rsum) maxres = res ind = -1 for i in range(n): if abs((lsum - col[i][0] + col[i][1]) - (rsum - col[i][1] + col[i][0])) > maxr...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.io.*; import java.math.*; import java.util.*; public class B { public static void main(String[] args) { try { (new Solver()).go(); } catch (Exception ex) { ex.printStackTrace(); } } } class Solver { public void go() { InputStream inputSt...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
a = [list(map(int, input().split())) for i in range(int(input()))] b = [i - j for i, j in a] mn, mx = b.index(min(b)), b.index(max(b)) s = sum(b) n = abs(s) p = abs(s - (b[mn] * 2)) f = abs(s - (b[mx] * 2)) print(((mx + 1, mn + 1)[p > f], (0, mn + 1)[p > n])[n > f])
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { int n, index = 0; cin >> n; int a[n][2]; long long int leftsum = 0, rightsum = 0, leftdiff = -1, rightdiff = -1, leftindex = 0, rightindex = 0; for (int i = 0; i < n; i++) { cin >> a[i][0]; cin >> a[i][1]; leftsum += a[i][0...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import math mat = [] neg,pos = 0,0 for i in range(int(input())): x,y = map(int,input().split()) mat.append(x-y) for i in mat: if i < 0: neg+=i else: pos+=i if pos == 0 or neg == 0: print(0) else: print(mat.index(max(mat)) + 1 if -neg + max(mat) > pos - min(mat) else mat.index(mi...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; long long n, sumr, suml, cr, cl, mr, ml, p; int main() { int ans = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { int a, b; scanf("%d %d", &a, &b); suml += a; sumr += b; if (a - b > cl) cl = a - b, ml = i; if (b - a > cr) cr = b - a, mr = i...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> const long long int mrx = 1e6 + 5, M = 1e9 + 7; long long int mx = -1e12, mn = 1e12; using namespace std; long long int a[mrx], d[mrx], b, z, e, mk, f, id, o, p; bool flag = true; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cin >> b; for (int i = 0; i < b; i++) { ci...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
l=lambda:map(int,raw_input().split()) n=input() diff=[0]*n for i in range(n): x,y=l() diff[i]=x-y total=sum(diff) maxi=abs(total) idx=-1 for i in range(n): t=abs(total-2*diff[i]) if maxi < t: maxi=t idx=i print idx+1
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
class CodeforcesTask733BSolution: def __init__(self): self.result = '' self.n = 0 self.columns = [] def read_input(self): self.n = int(input()) for x in range(self.n): self.columns.append([int(y) for y in input().split(" ")]) def process_task(self): ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n=int(input()) ar=[list(map(int,input().split())) for x in range(n)] L=0 R=0 for l,r in ar: L+=l R+=r best=abs(L-R) ans=0 i=1 for l,r in ar: L-=l L+=r R-=r R+=l if( abs(L-R) > best): best=abs(L-R) ans=i L+=l L-=r R+=r R-=l i+=1 print(ans)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.io.PrintWriter; import java.util.*; public class TaskB { public static void main(String[] args) { TaskB tB = new TaskB(); PrintWriter pw = new PrintWriter(System.out); tB.solve(new Scanner(System.in), pw); pw.close(); } public void solve(Scanner input, PrintWriter output) { int n...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
L,R = 0,0 p = [] for i in xrange(input()): l,r = map(int, raw_input().split()) L += l R += r p.append(l-r) if L > R: if max(p) > L-R: print p.index(max(p))+1 elif min(p) < 0: print p.index(min(p))+1 else: print 0 elif L < R: if min(p) < L-R: print p.index(min(p))+1 elif max(p) > 0: print p.index(max(...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
def mostBeauty(left,right): sumL=sum(left) sumR=sum(right) mb=abs(sumL-sumR) ans=0 for i in range(len(left)): mbc=abs((sumL-left[i]+right[i])-(sumR-right[i]+left[i])) if mbc>mb: mb=mbc ans=i+1 return ans #main num=input() left=[0 for i in range(num)] right=[0 for i in range(num)] for i in range(num): ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#!/usr/bin/python3 n = int(input()) l = [] r = [] for i in range(n): a, b = map(int, input().split()) l.append(a) r.append(b) L = sum(l) R = sum(r) mx = abs(L - R) k = 0 for i in range(n): Lp = L - l[i] + r[i] Rp = R - r[i] + l[i] if abs(Lp - Rp) > mx: mx = abs(Lp - Rp) k = i +...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) lrr = [] rrr = [] ls = 0 rs = 0 for i in range(n): a,b = map(int,input().split()) lrr.append(a) rrr.append(b) ls += a rs += b mx = abs(ls-rs) mxi = 0 for i in range(n): k = abs((ls-lrr[i]+rrr[i])-(rs-rrr[i]+lrr[i])) if(mx<k): mx = k mxi = i+1 print(mxi)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
r = lambda: map(int,input().split()) n = int(input()) l = [] for x in range(n): a,b = r() l.append(a-b) s = sum(l) new = [abs(s - 2*x) for x in l] m = max(new) if abs(s) >= m: print (0) else: print (new.index(m)+1)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(raw_input()) p = [map(int, raw_input().split()) for _ in xrange(n)] a = [pp[0]-pp[1] for pp in p] s = sum(a) mx = abs(s) ans = 0 for i in xrange(n): nx = abs(s-2*a[i]) if nx > mx: ans, mx = i+1, nx print ans
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
/* 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 Parade { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.Scanner; public class Parade { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] l = new int[n]; int[] r = new int[n]; for (int i = 0; i < n; i++) { l[i] = scan.nextInt(); r[i] = scan.nextInt(); } boolean happy = false; ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; unordered_map<long long, long long> m; unordered_map<long long, long long>::iterator itm; vector<long long> v; vector<long long>::iterator it; int main() { long long n, j, t, b[100005], i, mx = 0, a[100005], pos = -1, sumx = 0, sumy = 0,...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input("")) m1 = [0]*100005 m2 = [0]*100005 sum1 = 0 sum2 = 0 for i in range(n): m1[i],m2[i] = map(int, raw_input("").split(" ")) sum1 += m1[i] sum2 += m2[i] tmp = abs(sum1 - sum2) id = -1 for i in range(n): if abs((sum1 - m1[i] + m2[i]) - (sum2 - m2[i] + m1[i])) > tmp: tmp = abs((sum1 - ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; pair<int, int> arr[100100]; int main() { int n; cin >> n; int a, b; for (int i = 1; i <= n; ++i) { cin >> a >> b; arr[i].first = a + arr[i - 1].first; arr[i].second = b + arr[i - 1].second; } long long r = abs(arr[n].first - arr[n].second); int ind...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(raw_input()) a = [] s1 = 0 s2 = 0 mx = 0 pos = -1 for i in range(0,n): a.append(map(int, raw_input().split(' '))) s1 += a[i][0] s2 += a[i][1] mx = abs(s1-s2) for i in range(0,n): if mx<abs(s1-s2 - 2*a[i][0]+2*a[i][1]): mx = abs(s1-s2 - 2*a[i][0]+2*a[i][1]) pos = i print(pos+1)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.Scanner; public class Parade { public static void main(String[] args) { int n; Scanner sc=new Scanner(System.in); n=sc.nextInt(); int arr[][]=new int[n][2]; int L,R; L=R=0; for(int i=0;i<n;i++) { arr[i][0]=sc.nextI...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n=int(input()) l=[] for i in range (n): a,b=map(int,input().split()) l.append([a,b]) s1=0 s2=0 j=-1 for i in range(n): s1=s1+l[i][0] s2=s2+l[i][1] p=abs(s1-s2) for i in range(n): s3=s1-l[i][0]+l[i][1] s4=s2+l[i][0]-l[i][1] q=abs(s3-s4) if q>p: j=i p=q print(j+1)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n=int(input()) l=[0]*n r=[0]*n for i in range(n): l[i],r[i]=[int(s) for s in input().split()] sl=sum(l) sr=sum(r) m=abs(sl-sr) k=0 for i in range(n): new=abs(sl-sr+2*r[i]-2*l[i]) if new>m: m=new k=i+1 print(k)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; pair<int, int> arr[100005]; int main() { int n, s1, s2; s1 = s2 = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &arr[i].first, &arr[i].second); s1 += arr[i].first; s2 += arr[i].second; } int bt = abs(s1 - s2); int ans = 0, z; fo...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.*; import java.io.*; import java.math.*; import java.lang.*; /** * Created by vishakha on 13-10-2016. */ public class Problem { public static void main(String[] args) { FastReader sc = new FastReader(System.in); int cols = sc.nextInt(); int beauty = 0; int leftTo...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.Scanner; /** * * @author Gilbert */ public class Parade { public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int li[] = new int[n]; int ri[] = new int[n]; int L = 0,R = 0; int min = Integer.MAX_...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; pair<long long, long long> arr[100001]; int main() { long long n, tl = 0, tr = 0, s = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> arr[i].first >> arr[i].second; tl += arr[i].first, tr += arr[i].second; } for (int i = 1; i <= n; i++) { if (abs(tl...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.io.*; import java.util.*; import java.awt.*; public class div378B { BufferedReader in; PrintWriter ob; StringTokenizer st; public static void main(String[] args) throws IOException { new div378B().run(); } void run() throws IOException { //in=new BufferedReader(new FileReader("input.txt")); in=n...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { int n, l = 0, m = 0; cin >> n; int a[n + 1]; pair<int, int> p[n]; for (int i = 0; i < n; i++) { cin >> p[i].first >> p[i].second; l += p[i].first; m += p[i].second; } a[0] = abs(l - m); for (int i = 1; i < n + 1; i++) { l = l - p...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#!/usr/bin/python3 def parade(): n=int(input()) L=[] R=[] for i in range(n): a,b=map(int,input().strip().split()) L.append(a) R.append(b) Lsum=sum(L) Rsum=sum(R) Max_beauty=abs(Lsum-Rsum) id=0 for i in range(n): a=L[i] b=R[i] kmax=abs((Lsum-a+b)-(Rsum-b+a)) if kmax>Max_beauty: Max_b...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { long long t = 1; while (t--) { long long n, s = 0, s2 = 0, x, ans = -1; cin >> n; long long l[n + 1], r[n + 1]; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; s += l[i]; s2 += r[i]; } ans = abs(s - s2); x =...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
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 */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) Tot_x = 0; Tot_y = 0; MaxL = 0; MinL=99999999; MaxL_pos = 0; MinL_pos = 0; MaxR = 0; MinR=99999999; MaxR_pos = 0; MinR_pos = 0; for i in range(n): x,y = map(int,input().split()) Tot_x += x; Tot_y += y Lx = x-y if (Lx > MaxL): MaxL = Lx MaxL_pos = i+1 ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) coloms = [[None, None] for i in range(n)] for i in range(n): coloms[i][0], coloms[i][1] = map(int, input().split()) left_men = sum([t[0] for t in coloms]) right_men = sum([t[1] for t in coloms]) beauty = abs(left_men - right_men) first = beauty ans = 0 for i in range(n): colom = coloms[i] n...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { int s[100005], n, a, b, k; cin >> n; long long l = 0; long long r = 0; for (int i = 0; i < n; i++) { scanf("%d%d", &a, &b); s[i] = a - b; l += a; r += b; } int ans = abs(l - r); k = -1; for (int i = 0; i < n; i++) { long lo...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> const int Maxn = 1e5; int a[Maxn + 5], b[Maxn + 5], c[Maxn + 5]; int n, sum1, sum2; int x, cont; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i], &b[i]); sum1 += a[i]; sum2 += b[i]; } x = abs(sum1 - sum2); for (int i = 1; i <= n; i++) i...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import sys n = int(raw_input()) left = [] right = [] for _ in xrange(0, n): l,r = raw_input().strip().split(' ') l,r = [int(l),int(r)] left.append(l) right.append(r) sum_left = sum(left) sum_right = sum(right) beauty = abs(sum_left-sum_right) index = 0 for i in xrange(0, n): temp_sum_left = sum_left - left[i]...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) lr = [list(map(int, input().split())) for i in range(n)] d = [i[0]-i[1] for i in lr] dsum = sum(d) poss = [[abs(dsum), 0]] + [[abs(dsum - 2*d[i]), i+1] for i in range(n)] print(sorted(poss, reverse=1)[0][1])
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n=int(input()) a=[0]*n b=[0]*n c=[0]*n d=[] for i in range(n): a[i],b[i]=map(int,input().split()) c[i]=a[i]-b[i] sa=sum(a) sb=sum(b) if max(c)<=0 or min(c)>=0: print(0) else: for i in range(n): d.append(abs((sa-c[i])-(sb+c[i]))) print(d.index(max(d)) + 1)
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#!/usr/bin/python3.5 n = int(input()) couples = [] for i in range(n): co = input() co = co.split() co = list(map(int,co)) couples.append(co) l,r = 0,0 for i in couples: l += i[0] r += i[1] c = 0 dif = abs(l-r) index = -1 for i in couples: l_n , r_n = l - i[0] + i[1], r - i[1] + i[0] dif_n = abs(l_n-r_n) if di...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
# python2 import sys, threading, os.path import collections, heapq, math,bisect sys.setrecursionlimit(10**6) # max depth of recursion threading.stack_size(2**27) def main(): if os.path.exists('input.txt'): input = open('input.txt', 'r') else: input = sys.stdin #----------------------------...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int lc, rc; lc = 0; rc = 0; vector<pair<int, int> > values(n); for (int i = 0; i < n; i++) { cin >> values[i].first; cin >> values[i].second; lc = lc + values[i].first; rc = rc + values[i].second; } i...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author user */ public class Main { ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; namespace patch { template <typename T> std::string to_string(const T& n) { std::ostringstream stm; stm << n; return stm.str(); } } // namespace patch long long modpow(long long base, long long exponent, long long modulus) { long long result = 1; while (exponent ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { int n, l, r, L = 0, R = 0; cin >> n; vector<vector<int> > lr; vector<int> xd; for (int i = 0; i < n; i++) { cin >> l >> r; xd.push_back(l); xd.push_back(r); lr.push_back(xd); xd.clear(); L = L + l; R = R + r; } int max ...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int num, left = 0, right = 0, maxx = 0, l, r, res = 0; cin >> num; pair<int, int> pairr[num]; for (int i = 0; i < num; i++) { cin >> pairr[i].first >> pairr[i].second; left += pairr[i]...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
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 wannabe */ public class Main { public static void main(String[] args) { InputStream inputStre...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
n = int(input()) l, r = [], [] for _ in range(n): arr = [int(x) for x in input().split()] l.append(arr[0]) r.append(arr[1]) beauties = [l - r for l, r in zip(l, r)] total_beauty = sum(beauties) total_beauty_if_i_swaped = [total_beauty - 2 * x for x in beauties] if abs(total_beauty) < abs(max(total_beauty_if...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; /** * Created by AElah on 10/6/2016. */ public class B { public static void main(String [] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in...
Problem: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg rec...
import sys n=int(input()) a=[] b=[] p=0 q=0 for i in range(n): x=list(input().split(" ")) a.append(int(x[0])) b.append(int(x[1])) p+=int(x[0]) q+=int(x[1]) min=abs(p-q) j=0 for i in range(n): if abs(p-q-2*a[i]+2*b[i])>min: min=abs(p-q-2*a[i]+2*b[i]) j=i+1 print(j)