Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; typedef struct { int l, r; } TSave; const int N = 1000001; TSave a[N]; int main() { int n; long long L = 0, R = 0; scanf("%d", &n); for (int i = (0); i < (n); i++) { scanf("%d%d", &a[i].l, &a[i].r); L += a[i].l; R += a[i].r; } int ans = 0; long l...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
def f(l): ab = lambda x: x if x>0 else -x k = len(l) dl = [c[0]-c[1] for c in l] ss = sum(dl) mb = ab(ss) mi = 0 for i in range(k): b = ab(ss-(dl[i]<<1)) if b>mb: mi = i+1 mb = b return mi k = int(input()) l = [list(map(int,input().split())) for ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> a[n]; int diff[n]; int sumf = 0, sums = 0; int minidx, maxidx; int mindiff = INT_MAX, maxdiff = INT_MIN; for (int i = 0; i < n; ++i) { scanf("%d%d", &a[i].first, &a[i].second); diff[i] = a[i].first - a[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
# coding:utf-8 n = raw_input() n = int(n) v = [] zf = 0 ff = 0 for i in range(n): num = raw_input() num = num.split() a, b = int(num[0]), int(num[1]) dif = a-b v.append(dif) if dif >= 0: zf = 1 else: ff = 1 if zf + ff == 1: print(0) else: sum1 = 0 mmax = -1 ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import sys from operator import itemgetter n = int(sys.stdin.readline()) colons = [map(int, sys.stdin.readline().split()) for _ in range(n)] L = sum(map(itemgetter(0), colons)) R = sum(map(itemgetter(1), colons)) max_beauty = abs(L - R) max_beauty_i = 0 for i, (l, r) in enumerate(colons): _l = L - l + r _r...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import math n = int(input()) l = [0]*n r = [0]*n for i in range(n): l[i],r[i] = [int(i) for i in input().rsplit(' ')] s = 0 for i in range(n): s += l[i]-r[i] bestDiff = math.fabs(s) bestIndex = -1 for i in range(n): if math.fabs(s + 2*(r[i]-l[i])) > bestDiff: #print('YES',bestDiff,end = '-' ) ...
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()) maxl = 0 maxr = 0 total = 0 li = 0 ri = 0 x = -1 for i in range(n): l, r = map(int, input().split()) val = l - r if val<maxr: maxr = val ri = i+1 elif val>maxl: maxl = val li = i+1 total += val if abs(total) < abs(total - 2 * maxl): x = li tot...
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 a[105], n, m, k; int color[200005]; bool visited[200005]; map<int, int> cnt; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int ret; vector<vector<int> > adjlist; long long power(long long a, long long b) { if (b == 1) { return a; } if (b == 0) { retu...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; import java.io.*; import java.math.*; public class Test1{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] arr = new int[n][2]; for(int i=0;i<n;i++){ arr[i][0] = sc.nextInt(); arr[i][1] = sc.nextInt(); } int left_beauty = 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()) l, r = [0]*n, [0]*n for i in range(n): l[i], r[i] = map(int, input().split(" ")) L, R = sum(l), sum(r) index, beauty = -1, abs(L-R) for i in range(n): t = abs((L-l[i]+r[i]) - (R-r[i]+l[i])) if t > beauty: index, beauty = i, t print(index+1)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
t = int(input()) l,r = [],[] c1,c2=0,0 for i in range(t): a,b = map(int,input().split()) l.append(a) r.append(b) c1+=a c2+=b c = abs(c1-c2) d = 0 n = c for i in range(t): e = abs((c1-l[i]+r[i])-(c2-r[i]+l[i])) if e>n: d=i+1 n = e print(d)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import math,sys from collections import Counter, defaultdict, deque from sys import stdin, stdout input = stdin.readline li = lambda:list(map(int,input().split())) def solve(): n=int(input()) a=[] s=0 t=0 for i in range(n): p,q=li() s+=p t+=q a.append([p,q]) k=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
T = int(raw_input()) M = -float('inf') m = float('inf') S = 0 temp = [] newS = [] for i in xrange(T): a, b = map(int, raw_input().split() ) S += (a - b) temp.append(b - a) newS = [abs(S + 2 * temp[i]) for i in xrange(T)] newS.append(abs(S)) idx = newS.index(max(newS)) if idx == T: print 0 else: 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
//Codeforces Round #378 (Div. 2) import java.io.*; import java.util.*; public class TaskB { public static void main (String[] args) throws IOException { FastScanner fs = new FastScanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = fs.nextInt(); int[] l = new int[n]; int...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) L,R=[],[] l,r=0,0 for i in range(n): ch=(input().split()) L.append(int(ch[0])) l+=int(ch[0]) r+=int(ch[1]) R.append(int(ch[1])) be=abs(l-r) a=0 for i in range(n): if abs((l+R[i]-L[i])-(r-R[i]+L[i]))>be: be=abs((l+R[i]-L[i])-(r-R[i]+L[i])) a=i+1 print(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
n = int(raw_input()) left = [] right = [] for i in range(n): a, b = map(int, raw_input().split()) left.append(a) right.append(b) L = sum(left) R = sum(right) beauty = abs(L - R) best = beauty best_col = -1 for i in range(n): L -= left[i] R -= right[i] L += right[i] R += left[i] cur = ab...
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()) left, right = [], [] L = R = 0 for _ in range(n): l,r = map(int, input().split()) left.append(l) right.append(r) L += l R += r max_k, max_i = abs(L-R), -1 for i in range(n): Li = L - left[i] + right[i] Ri = R - right[i] + left[i] k = abs(Li-Ri) if k > 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
import java.util.*; public class Parade{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] left = new int[n]; int[] right = new int[n]; int lSum = 0; int rSum = 0; for(int i = 0; i < n; i++){ ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) d_vec = [0] for i in range(n): l, u = [int(i) for i in input().split()] d_vec.append(l - u) d_sum = sum(d_vec) d_vec = [abs(d_sum - 2*d) for d in d_vec] d_max = max(d_vec) print(d_vec.index(d_max))
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
a = int(input()) v,r,t,l =[],0,-1,0 for i in range(a): q,w= map(int,input().split()) v.append([q,w]) l+=q;r+=w b = abs(l-r) for i in range(len(v)): w = abs((l+v[i][1]-v[i][0])-(r+v[i][0]-v[i][1])) if w>b:t,b = i,w print(t+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.util.Scanner; public class Solution { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); // Scanner sc = new Scanner(new File("in.txt")); int n = sc.nextInt(); int[] cols = new int[n]; int totalDiff = 0; for(int i=1; i<=n; i++){ cols[i-1] = sc.n...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) left = [] right = [] dif1 = [] dif2 = [] total = [] for i in range(n): l, r = map(int, input().split()) left.append(l) right.append(r) if l>r: dif1.append((abs(l-r),i)) else: dif2.append((abs(l-r),i)) total.append((abs(sum(left)-sum(right)),0)) try: left[max(dif1...
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
# In this template you are not required to write code in main import sys inf = float("inf") #from cmath import sqrt #from collections import deque, Counter, OrderedDict,defaultdict #from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace from math import ceil,floor,log,sqrt,factorial,pow,pi,gc...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
t=int(input()) sum1=0 sum2=0 ans=[] l=[] for _ in range(t): n,m=map(int,input().split()) l.append([n,m]) sum1+=n sum2+=m final=abs(sum1-sum2) ind=-1 for i in range(t): temp=sum1 temp2=sum2 temp=temp-l[i][0]+l[i][1] temp2=temp2-l[i][1]+l[i][0] if abs(temp-temp2)>final: final=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
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double PI = acos(-1.0); const int inf = (int)1e9 + 7; const long long INF = (long long)1e18 + 7; const int mod = (int)1e9 + 7; const int N = (int)2e5 + 7; int n, l[N], r[N], R, L, ans, maxi; int main() { ios_base::sync_with_stdio(0); cin.t...
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.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l =...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; int x[maxn]; int y[maxn]; int n, sum1, sum2, ans; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; } for (int i = 1; i <= n; i++) { sum1 += x[i]; sum2 += y[i]; } int mx = abs(sum1 - sum2); for (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
#!/usr/bin/env python3 # -*- coding: utf-8 -*- n=int(input()) d=[] for i in range(n): a,b=map(int,input().split()) d.append([a,b]) L,R=0,0 for i in range(n): L+=d[i][0] R+=d[i][1] max=abs(L-R) imax=-5 for i in range(n): if abs(L-2*d[i][0]+2*d[i][1]-R)>max: max=abs(L-2*d[i][0]+2*d[i][1]-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
import java.lang.*; import java.io.*; import java.util.*; public class C733B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int [] l = new int[n]; int [] r = new int[n]; int sumL = 0, sumR = 0; boolean LR = f...
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[100001], R[100001]; int main() { int n, i, l = 0, r = 0, x, k, ret = 0, val; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d %d", L + i, R + i); l += L[i]; r += R[i]; } x = l - r; val = (int)abs(x); for (i = 1; i <= n; i++) { k = x ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class Parade { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int sL=0, sR=0; int[][] a = new int[n][2]; for(int i = 0; i < n; i++) { a[i][0]=scan.nextInt(); a[i][1]=scan.nextInt(); sL+=a[i][0]; sR+=a[i][1]; ...
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
if __name__ == '__main__': n = input() l, r = [], [] for _ in xrange(n): s = raw_input().split() l.append(int(s[0])) r.append(int(s[1])) L, R = 0, 0 for i in xrange(n): L += l[i] R += r[i] res = 0 Nmax = 0 for i in xrange(n): N = abs(L-R-2*l[i]+2*r[i]) if N > Nmax: res = i Nmax = N if Nmax...
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=[] l2=0 r1=0 for i in range(n): l1,r=list(map(int,input().split())) l2+=l1 r1+=r l.append([l1,r]) maxim=abs(l2-r1) ind=-1 for i in range(n): s=abs((l2-l[i][0]+l[i][1])-(r1+l[i][0]-l[i][1])) if s>maxim: maxim=s ind=i print(ind+1)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) col = [] r = 0 l = 0 for i in range(n): col.append([int (x) for x in input().split()]) l += col[i][0] r += col[i][1] beauty = abs(r-l) best = -1 best_be = beauty for i in range(n): r1,l1 = col[i] diff = r1-l1 b2 = abs(r-l+2*diff) if b2 > best_be: best_be = ...
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[1000000], r[1000000]; int main() { int n, L = 0, R = 0, d, cl, cr, a, b, D, f = 0, I; 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; i < n; i++) { cl = r[i]; cr = 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
n = int(input()) l = [] r = [] d = [] L = 0 R = 0 for i in range(n): tmp1, tmp2 = map(int,input().split()) l.append(tmp1) r.append(tmp2) L += tmp1 R += tmp2 dif = L - R selectedDif = dif selectedID = 0 for i in range(n): newDif = dif - 2*(l[i] - r[i]) if abs(selectedDif) < abs(newDif): ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package cf; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; imp...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import static java.lang.Math.*; import java.math.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System....
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[100001], r[100001], i, j, k, n, mx, S, L, R, a, b; int main() { cin >> n; for (i = 1; i <= n; ++i) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } mx = abs(L - R); k = 0; a = L; b = R; for (i = 1; i <= n; ++i) { a = a - l[i] + r[i]; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; long sumOf(int *array, int length) { int temp{0}; for (int i = 0; i < length; ++i) temp += array[i]; return temp; } int main() { int col, maxBeauty{0}, colChange{-1}; cin >> col; int marchl[col], marchr[col]; for (int i = 0; i < col; ++i) cin >> marchl[i] >> m...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, f, g = 0, right = 0, left = 0, low = 0, high = 0, i, x, post2, h = 0, sum1, sum2, post, pre, y, m = 0, n = 0; cin >> a; for (i = 0; i < a; i++) { cin >> b >> c; f = b -...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class parade { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int col = scan.nextInt(); int[] left = new int[col]; int[] right = new int[col]; int leftTot = 0; int rightTot = 0; //get total int beau; int result = 0; int tempLeft...
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[1000010]; int r[1000010]; int sum = 0; int sum2 = 0; int mx; int idx = 0; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int a, b; scanf("%d%d", &a, &b); l[i] = a; r[i] = b; sum += a; sum2 += b; } mx = sum2 - sum; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
z=int(input()) d=[] s=[] for i in range(z): x=list(map(int,input().split())) d.append(x[0]) s.append(x[1]) l=0 r=0 for i in s: l+=i for o in d: r+=o df=abs(l-r) qa=[] for i in range(len(s)): a=l b=r a-=s[i] a+=d[i] b-=d[i] b+=s[i] qa.append(abs(a-b)) sa=qa.index(...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { int n=sc.nextInt(); int max1=0,maxi1=0,max2=0,maxi2=0,f1=0,f2=0,sum1=0,sum2=0; for(int i=0;i<n;i++) { int l=sc.nextInt(),r=sc.nextInt(); sum1+=...
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 = input() l = 0 r = 0 fir = [] sec = [] for _ in xrange(n): a,b = map(int,raw_input().split()) fir.append(a) sec.append(b) l += a r += b d = abs(l-r) cur = d ind = 0 if l > r: for i in xrange(n): a = fir[i]-sec[i] if a > 0: if 2*a -d > cur: cur = 2*a - d ind = i+1 else: if 2*abs(a) + d > cu...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int l[n], r[n]; for (int i = 0; i < n; i++) cin >> l[i] >> r[i]; int lsum = 0, rsum = 0; for (int i = 0; i < n; i++) { lsum += l[i]; rsum += r[i]; } int maxdiff = abs(lsum - rsum), maxdiffindex = 0; bool ispossible = f...
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
#!/usr/bin/env python3 def main(): n = int(input()) l = [0] * n r = [0] * n for i in range(n): l[i], r[i] = [int(x) for x in input().split()] total_r = sum(r) total_l = sum(l) beauty = abs(total_l - total_r) new_beauty, row = max(( abs(total_l-total_r + 2*r[i] - 2*l[i]) , i) fo...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class parade { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(), i, l_total=0, r_total=0, beauty, max_diff=0, min_diff=0; int[] l=new int[n]; int[] r=new int[n]; int[] diff=new int[n]; for (i=0; i<n; i++) { l[i]=scan.nex...
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, a[100005], b[100005], now, mx, swt; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; now += a[i] - b[i]; } mx = max({mx, abs(now)}); for (int i = 0; i < n; ++i) { if (abs(now - a[i] + b[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.util.*; import java.io.*; public class B { FastScanner in; PrintWriter out; boolean systemIO = true; public void solve() { int n = in.nextInt(); int[] a = new int[n]; int sum = 0; for (int i = 0; i < a.length; i++) { a[i] = in.nextInt() - in.nextInt(); sum += a[i]; } int max = M...
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 parad(l, r): s1, s2 = sum(l), sum(r) ans, ch = abs(s1 - s2), 0 for i in range(len(l)): z = abs(((s1 - l[i]) + r[i]) - ((s2 - r[i]) + l[i])) if z > ans: ans, ch = z, i + 1 return ch n = int(input()) L, R = list(), list() for j in range(n): s, t = [int(x) for...
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> int main() { int n; std::map<int, int> m; std::cin >> n; std::vector<int> deviations(n); int total = 0; for (int i = 0; i < n; ++i) { int l, r; std::cin >> l >> r; total = total + l - r; deviations[i] = 2 * r - 2 * l; } for (int i = 0; i < n; ++i) { m.insert(...
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
number = int(raw_input()) left,right = {},{} for i in xrange(number): a,b = (raw_input().strip()).split() a,b = int(a),int(b) left[i] = a right[i] = b suml,sumr = sum(left.values()), sum(right.values()) diff = {} checkl,checkr = 1,1 for i in xrange(number): diff[i] = left[i] - right[i] if le...
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 = [] L = 0 R = 0 d = 0 chg = 0 for i in range(n): a, b = map(int, input().split()) l.append(a) r.append(b) L = L + l[i] R = R + r[i] d = abs(L-R) for i in range(n): if d < abs((L-l[i]+r[i]) - (R-r[i]+l[i])): d = abs((L-l[i]+r[i]) - (R-r[i]+l[i])) chg = i+1 print(chg)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Marazzi Francesco */ public class Main { public static void main(String[] args) { Inp...
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
number_of_column = int(raw_input()) L, R = [], [] for i in range(number_of_column): l, r = map(int, raw_input().split()) L.append(l) R.append(r) max_seed = abs(sum(L) - sum(R)) max_temp, max_index = -1, -1 sum_left_total = sum(L) sum_right_total = sum(R) for i in range(number_of_column): new_left_sum...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; long int abc(long int x) { if (x < 0) return -x; else return x; } int main() { long int n, a, b, suma = 0, sumb = 0, maxa = 0, maxb = 0, na = 0, nb = 0, ans1, ans2, ans3; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; su...
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 = 1e6 + 100; pair<pair<int, int>, int> val[maxn]; long long res = 0; long long resind = 0; int main() { ios::sync_with_stdio(false); int n; cin >> n; int sum = 0; for (int i = 0; i < n; i++) { cin >> val[i].first.first >> val[i].first.second; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) T=[] J=[] l=0 r=0 for i in range(n): L,R=map(int,input().split()) T.append(L) J.append(R) l+=L r+=R B=abs(l-r) ind=0 for i in range(n): x=T[i] y=J[i] h=abs((l-x+y)-(r+x-y)) if B<h: B=h ind=i+1 print(ind)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) ans = 0 l = 0 r = 0 ml = 0 mr = 0 a = [] for i in range(n): x,y = map(int,input().split()) a.append((x,y)) l+=x r+=y best = abs(l - r) c = 0 new = 0 for v in a: c+=1 nl = l nr = r nl = nl - v[0] + v[1] nr = nr - v[1] + v[0] if abs(nl-nr) > best: new = c ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) columns = [] l_tot = 0 r_tot = 0 for i in range(n): l, r = [int(j) for j in input().split()] columns.append((l, r)) l_tot += l r_tot += r beauty = abs(l_tot - r_tot) best_idx = -1 for i, c in enumerate(columns): l, r = c tmp_beauty = abs((l_tot - l + r) - (r_tot - r + l)) if...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Thu Nov 3 19:54:47 2016 @author: KFakharany """ numberofcolumns = input() sumL = 0 sumR = 0 change = 0 inputs = [None] * (numberofcolumns * 2) for i in range(numberofcolumns) : a=map(int,raw_input().split()) inputs[i*2]=a[0] inputs[(i*2)+1]=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 sun.rmi.server.InactiveGroupException; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; PrintStream out = System.out; // try { // inputStream = new FileInputStream("input.txt"); // ...
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()) pairs,lsum,rsum=[],0,0 for i in range(n): a,b=map(int,input().split()) pairs.append((a,b)) lsum+=a rsum+=b x=abs(lsum-rsum) index=-1 for i in range(n): l,r=lsum,rsum l=l-pairs[i][0] r=r-pairs[i][1] l+=pairs[i][1] r+=pairs[i][0] a=abs(l-r) if a>x: x=a index=i+1 if index==-1: print(0) else:...
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()) buff = [] for i in range(n): a, b = map(int, input().strip().split()) buff.append(a - b) answ = 0 for i in range(n): answ += buff[i] answ = math.fabs(answ) l = 0 k = 0 mi = buff.index(min(buff)) ma = buff.index(max(buff)) buff[mi] = -1 * buff[mi] for i in range(n): k += buff...
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; const int maxn = 1e5 + 5; inline int abx(int x) { if (x > 0) return x; else return -x; } inline int Mx(int x, int y) { if (x > y) return x; else return y; } int n, l[maxn], r[maxn]; int ans, maxm, maxl, maxr, tmpl, tmpr; int main() { memset(l, 0, 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
n = int(input()) ALLL = 0 ALLR = 0 MLP = 0 MRP = 0 MLPI = 0 MRPI = 0 for i in range(n): inp = input().split() L = int(inp[0]) R = int(inp[1]) ALLL += L ALLR += R LP = R - L RP = L - R if LP>MLP: MLP = LP MLPI = i if RP>MRP: MRP = RP MRPI = i ML = ALLL - ALLR + 2*MLP MR = ALLR - ALLL + 2*MRP if...
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.util.regex.*; public class Main { public static void main(String[] args) { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); Scanner scan = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = scan.nextI...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int big = 1e5 + 7; int l[big], r[big], record[big]; int main() { int n, num = 0, p = 0, q = 0, large, temp; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &l[i], &r[i]); p += l[i]; q += r[i]; } large = p - q; if (large < 0) larg...
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.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Tr...
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 a[100005], b[100005]; int main() { int n, s1 = 0, s2 = 0, max, col = 0; cin >> n; for (int i = 1; i <= n; ++i) { int x, y; cin >> x >> y; s2 += y; s1 += x; a[i] = x; b[i] = y; } max = abs(s1 - s2); for (int i = 1; i <= n; ++i) { 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.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int i =0; List<Integer> left = new ArrayList<Integer>(); List<Integer> right = new ArrayList<Integer>(); 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
if __name__=='__main__': n = int(input()) a,b = list(),list() for _ in range(n): x,y = map(int,input().split()) a.append(x) b.append(y) ll1 = sum(a) rr1 = sum(b) res = abs(ll1-rr1) ans = 0 for i in range(n): ll = ll1 rr = rr1 ll -= a[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; const int maxn = 1000050; int n, suml, sumr, l[maxn], r[maxn]; void init() { suml = sumr = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &l[i], &r[i]); suml += l[i]; sumr += r[i]; } } void work() { int maxb = abs(suml - sumr), ans = 0...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.net.HttpURLConnection; import java.net.URLConnection; import java.util.Scanner; import java.util.StringTokenizer; /** * Created by hapsidra on 22.10.2016. */ public class Main { public static class FastScanner { BufferedReader br; StringTokenizer st; public ...
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 itertools from fractions import gcd from math import sqrt from bisect import bisect_left import heapq def get(a): return map(a , raw_input().split()) def I(): return int(raw_input()) def Str(): return raw_input() n = I() store = [] sm_1 , sm_2 = 0,0 for i in xrange(n): a , b = get(int) store.append((a,b))...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int l[100100], r[100100], a[100100]; int main() { int n, lsum, rsum, x, m, f; while (~scanf("%d", &n)) { lsum = 0; rsum = 0; for (int i = 1; i <= n; i++) { scanf("%d%d", &l[i], &r[i]); lsum += l[i]; rsum += r[i]; } m = abs(lsum - rs...
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 */ public class Main { public static void main(String[] args) { InputStream inputStream = System.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.io.*; import java.util.*; public final class cf378div2Bfinal { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int[][] a=new int[n][2]; int max,suml=0,sumr=0,sumrf=0,sumlf=0; for(int i=0;i<n;i++){ a[i][0]=in.nextInt(); a[i][1]=in.nextIn...
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 arr[10000000], brr[10000000]; int main() { int n, i, j, k, l, t, r, e = 0; ; int mi = 1; cin >> n; long long sum = 0, rum = 0, d, m; for (i = 0; i < n; i++) { cin >> arr[i] >> brr[i]; sum += arr[i]; rum += brr[i]; } long long mx = abs(sum - r...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import sys import math import itertools import collections def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(map(int, input().split())) def lcm(a, b): return abs(a * b) // math.gcd(a, b) def wr(arr): return ' '.join(map(str, arr)) def revn(n): return str(n)[::-1] def dd():...
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, r = 0, l = 0; vector<int> d; cin >> n; d.resize(n); for (int i = 0; i < n; ++i) { int x, y; cin >> x >> y; l += x; r += y; d[i] = x - y; } int maxx = abs(r - l), n_max = -1; for (int i = 0; i < n; ++i) { int dl = 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> arr[100009]; int main() { int n; scanf("%d", &n); long long L = 0, R = 0; for (int i = 0; i < n; i++) { cin >> arr[i].first >> arr[i].second; L += arr[i].first; R += arr[i].second; } long long mx = ((L - R) > 0 ? (L - R) : ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) l=[list(map(int,input().split())) for _ in range(n)] for i in range(n): l[i]=l[i][0]-l[i][1] ans=0 su=sum(l) ma=abs(su) for i in range(n): if abs(su-l[i]-l[i])>ma: ma=abs(su-l[i]-l[i]); 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
// Working program with FastReader import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class TestClass { static class FastReader { BufferedReader br; StringTokenizer st;...
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; while (cin >> n) { int L, R; L = R = 0; vector<int> r(n, 0), l(n, 0); for (int i = 0; i < n; ++i) { cin >> l[i] >> r[i]; L += l[i]; R += r[i]; } int ans = 0, b = abs(L - R); for (int i = 0; i < n; ++i) { ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int n, x[1000001], y[1000001]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n; vector<int> vec; long long sum1 = 0, sum2 = 0; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; sum1 += x[i]; sum2 += y[i]; } int ans1 = 0, ans2 ...
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
arr = [] L, R = 0, 0 for _ in range(int(input().strip())): l, r = map(int, input().strip().split()) L += l R += r arr.append((l, r)) currBeauty = abs(L-R) ans = 0 for i in range(len(arr)): l, r = arr[i] newL = L-l+r newR = R-r+l newBeauty = abs(newL-newR) if newBeauty > currBeauty: currBeauty = newBeauty 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
n = int(input()); l = [0] * n; r = [0] * n; cur_res = 0; for i in range(n): l[i], r[i] = [int(x) for x in input().split()]; cur_res += l[i] - r[i]; max_res = abs(cur_res); max_indx = -1; for i in range(n): tmp_res = abs(cur_res - 2 * (l[i] - r[i])); if tmp_res > max_res: max_res = tmp_res; ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = input() a = [0] * n for i in range(n): x, y = map(int, raw_input().split()) a[i] = x - y s = sum(a) j = -1 m = abs(s) for i in range(n): if abs(s - 2*a[i]) > m: j = i m = abs(s - 2*a[i]) print j + 1
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Code { public static void main(String[] args) { // Use the Scanner class Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n]; int[] r = new int[n]; for ...
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 t, n, a, b, high1, high2, temp1, temp2, cat1, cat2, c, d, e, f; long long sum1 = 0, sum2 = 0, s1, s2, ss1, ss2; cin >> t; n = 1; int l = 0, r = 0; high1 = -9999999; high2 = -9999999; cat1 = 0; cat2 = 0; while (n <= t) { cin >> a >> b...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
from sys import stdin lines = stdin.read().splitlines() lines.pop(0) rows = [] initialLeftSum = 0 initialRightSum = 0 for line in lines: row = [int(x) for x in line.split()] rows.append(row) initialLeftSum += row[0] initialRightSum += row[1] maxBeauty = abs(initialLeftSum - initialRightSum) rowtoswi...
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; const int INF = 0x3f3f3f3f; const long long LINF = 2e18; const double PI = acos(-1.0); const double E = exp(1); const double EPS = 1e-8; const long long mod = 1e4 + 7; const int maxn = 1e2 + 5; void pre() { freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; import org.omg.PortableInterceptor.INACTIVE; public class CodeforcesRound378 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int l[] = new int[n+1], r[] = new int[n+1]; int max = 0, L = 0, R = 0, maxIndex = 0; for (int i=...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) t = [] for i in range(n): l, r = map(int, input().split()) t.append((l, r)) L = 0 R = 0 for i in t: L += i[0] R += i[1] m = abs(L - R) mi = 0 for i in range(n): l, r = t[i][0], t[i][1] if l == r: continue d = abs((L - l + r) - (R - r + l)) if d > m: 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
n=int(input()) arr = [tuple(map(int, input().split())) for i in range(n)] sl, sr = (0,0) for h in arr: sl+=h[0]; sr+=h[1] mx, a, i = abs(sl-sr), -1, 0 for h in arr: si = abs((sl-h[0]+h[1]) - (sr-h[1]+h[0])) if si>mx: mx,a=si,i i+=1 print(a+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.util.Arrays; import java.util.Scanner; public class Main { 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]; for (int i = 0; i < n; i++) { l[i] = sc.nextInt(); r[i] = sc.nextInt(); } System.o...
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
#! /usr/bin/env python # -*- coding: utf-8 -*- if __name__ == '__main__': n = raw_input() l = [] ll = [] sum_a, sum_b = 0, 0 for i in range(int(n)): a = raw_input().split(' ') l.append(int(a[0])-int(a[1])) ll.append((int(a[0]),int(a[1]))) sum_a += int(a[0]) s...
PYTHON