Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(raw_input()) l = [] r = [] sl = 0 sr = 0 for i in range(n): tl, tr = map(int, raw_input().split()) l.append(tl) r.append(tr) sl += tl sr += tr maxsum = abs(sl - sr) ans = 0 for i in range(n): temp = abs(sl - l[i] + r[i] - sr - l[i] + r[i]) if temp > maxsum: maxsum = temp ...
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 arr1[n]; int arr2[n]; int diff[n]; long long sum1 = 0; long long sum2 = 0; for (int i = 0; i < n; i++) { cin >> arr1[i]; cin >> arr2[i]; diff[i] = arr1[i] - arr2[i]; sum1 += arr1[i]; sum2 += arr2[i]; } ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int a[100000], b[100000], n; int main() { scanf("%d", &n); int l = 0, r = 0; for (int i = 0; i < n; i++) { scanf("%d %d", &a[i], &b[i]); l += a[i]; r += b[i]; } int idx = 0; int res = l - r; if (res < 0) res = -res; for (int i = 0; i < n; i++) { ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) l,r,sl,sr,mx,ans = [],[],0,0,0,0 for i in range(n): l1,r1 = map(int,input().split()) l.append(l1) r.append(r1) sl+=l1 sr+=r1 mx = abs(sl-sr) for i in range(n): sl = abs(sl-l[i]+r[i]) sr = abs(sr-r[i]+l[i]) t1 = abs(sl-sr) if t1>mx: mx = t1 ans = i+1 ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(raw_input()) l = [] x,y = 0,0 for i in range(n): a,b = map(int,raw_input().split()) l+=[(a,b)] x += a; y += b ansval = abs(x-y) ans = 0 for i in range(n): a,b = l[i] x+= -a + b y+= - b + a if ansval < abs(x-y): ans = i+1 ansval = abs(x-y) # print ans, ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[][] a = new int[n][2]; int l = 0, r = 0; for(int i = 0; i < n; i++){ int x = scan.nextInt(), y = scan.nextInt(); a[i][0] = x; a[i][1] = y; 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 MAX_N = 100005; pair<int, int> a[MAX_N]; int main() { int n; scanf("%d", &n); int sum_l = 0, sum_r = 0; for (int i = 1; i <= n; i++) { scanf("%d %d", &a[i].first, &a[i].second); sum_l += a[i].first; sum_r += a[i].second; } int dif = abs(sum...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> l(n), r(n); int sml = 0, smr = 0; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; sml += l[i]; smr += r[i]; } int mxb = abs(sml - smr); int col = 0; for (int i = 0; i < n; i++) { if (abs(sml - 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
l = [0] for _ in range(int(input())): a, b = map(int, input().split()) l.append(a - b) s, a, b = sum(l), min(l), max(l) print(l.index(a if a + b < s else b))
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 R = 0 a = [] pas = 0 for _ in range(n): l, r = map(int,input().split()) L += l R += r a.append(l - r) b = abs(L - R) k = b for i in range (n): if abs((L-a[i])-(R+a[i])) > k: k = abs((L-a[i]) - (R+a[i])) pas = i + 1 if k==b: print(0) else: print(pas)
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
/** * Created by My PC on 31/10/2016. */ import javax.swing.plaf.metal.MetalTheme; import java.lang.reflect.Array; import java.util.*; public class B { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int[] l = new int[n]; ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import sys def abs_value(a,b): v = a-b if v == 0 : return 0 elif v < 0 : return -1*(v) elif v > 0 : return v n = input() left = [] right = [] sum_l = 0 sum_r = 0 for i in range(0,n) : l,r = map(int,sys.stdin.readline().split()) sum_l += l sum_r += r left.appen...
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()) lst = [] left = 0 right = 0 for i in range(n): l, r = map(int, input().split()) left += l right += r lst.append((l, r)) max_beaty = abs(left - right) row = 0 for i in range(n): l, r = lst[i] left -= l left += r right -= r right += l if abs(left - right) > max_bea...
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 inff = 0x3f3f3f3f3f3f3f3f; int n; int l[100010], r[100010]; long long sl = 0, sr = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> 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
n = int(raw_input()) left=[0]*n right=[0]*n for i in range(n): left[i], right[i] = map(int, raw_input().split()) left_sum = sum(left) right_sum = sum(right) maxB = abs(left_sum - right_sum) index = 0 for i in range(n): l = left_sum r = right_sum l -= left[i] r -= right[i] l += right[i] r += ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n, l[100002], r[100002], d[100002], s = 0, max, m; cin >> n; for (int i = 0; i < n; i++) { cin >> l[i] >> r[i]; d[i] = l[i] - r[i]; s += d[i]; } max = -1; m = s; for (int i = 0; i < n; i++) { if (abs(-2 * d[i] + s) > abs(...
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; using namespace std; const int maxn = 100000 + 10; int l[maxn]; int r[maxn]; int main() { int n; cin >> n; int left = 0; int right = 0; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; left += l[i]; right += r[i]; } int tmp = abs(left - right); ...
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.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Parade { public static void main(String[] args) { int[][] prade = null; int iLeft = 0; int iRight = 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
l = [0] for _ in range(int(input())): a, b = map(int, input().split()) l.append(a - b) s, a, b = sum(l), min(l), max(l) print(l.index(a) if a + b < s else l.index(b))
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 = input().replace(".Frankenstein.", ".Frankenstein's.monster.") # if a[:13] == "Frankenstein.": # a = "Frankenstein's.monster." + a[13:] # if a[-13:] == ".Frankenstein": # a = a[:-13] + ".Frankenstein's.monster" # print(a) #compress a string to be the following: #ahahahah -> ah4 #blahblehbleh -> blah1ble...
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()) togetherL = 0 togetherR = 0 l = [] r = [] max = 0 for i in range(n): tmp = input().split() l.append(int(tmp[0])) r.append(int(tmp[1])) togetherL = togetherL + l[i] togetherR = togetherR + r[i] mod = abs(togetherL - togetherR) for i in range(n): if abs((togetherL - l[i] + r[i]) -...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
//package cf378; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; public class cf2{ public static void main(String[] args){ ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
if __name__ == '__main__': n = int(input()) init_f = True min_p = max_p = -1 min_v = max_v = sum_v = 0 for i in range(n): a, b = str(input()).split() miss = int(a) - int(b) sum_v += miss if init_f: init_f = False min_p = max_p = i + 1 ...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.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 toshif */ public class Main { public static void main(String[] args) { InputStream 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
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> p[110000]; int i, j, n, sl = 0, sr = 0, x, y, c = 0, h, r; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d%d", &p[i].first, &p[i].second); sl += p[i].first; sr += p[i].second; } h = abs(sl - sr); for (i = 1; i <= n...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
from copy import deepcopy def f(n, m): return abs(n - m) n = int(input()) mas = [] L = 0 R = 0 for i in range(n): l, r = map(int, input().split()) mas.append((l, r)) L += l R += r sum = f(L, R) old = deepcopy(sum) new = deepcopy(old) #print(L, R) for i in range(n): L -= mas[i][0] R -= mas[...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
N = int(input()) L = [] R = [] for i in range(N): l, r = map(int, input().split()) L.append(l) R.append(r) lsum = sum(L) rsum = sum(R) ans = abs(lsum - rsum) ansi = 0 for i in range(N): nlsum = lsum - L[i] + R[i] nrsum = rsum - R[i] + L[i] nans = abs(nlsum - nrsum) if nans > ans: ans...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long ans = 0; long long total; long long tleft = 0; long long tright = 0; vector<pair<long long, long long> > soldier; for (long long i = 0; i < n; i++) { long long a, b; cin >> a >> b; soldier.push_back(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(int argc, char** argv) { int n; cin >> n; vector<int> l, r; for (int i = 0; i < n; i++) { int l0, r0; cin >> l0 >> r0; l.push_back(l0); r.push_back(r0); } int totalL = accumulate(l.begin(), l.end(), 0); int totalR = accumulate(r.begin(...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) a = [0] * (n+1) s = 0 for i in range(1, n+1): l, r = map(int, input().split()) a[i] = l-r s += a[i] maxx = s q = 0 for i in range(1, n+1): if abs(s-a[i]-a[i]) > abs(maxx): q = i maxx = s-a[i]-a[i] print(q)
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 = list(list(map(int, input().split())) for i in range(n)) d = [i[0]-i[1] for i in arr] dsum = sum(d) res = [[abs(dsum), 0]] res += [[abs(dsum - 2 * d[i]), i+1] for i in range(n)] print(sorted(res, reverse=True)[0][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.*; public class parade { public static void main(String args[]) { Scanner ex=new Scanner(System.in); int n=ex.nextInt(); int arr[][]=new int[2][n]; int diffl=0,diffr=0,posr=-1,posl=-1,tl=0,tr=0; for(int i=0;i<n;i++) { arr[0][i]=ex.next...
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 l[100000]; int r[100000]; long n; cin >> n; int SL = 0, SR = 0; for (int i = 0; i < n; ++i) { cin >> l[i] >> r[i]; SL += l[i]; SR += r[i]; } int p = -1; int max = abs(SL - SR); for (int i = 0; i < n; ++i) { if (abs((SL - ...
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; mt19937 gen; inline int rnd(int x) { return gen() % x; } const int INF = (int)1.01e9; const int MOD = 1000000007; const double EPS = 1e-9; const double PI = acos(-1); vector<pair<int, int> > kek; bool solve() { int n; if (scanf("%d", &n) < 1) return false; long 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
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, a, b, s1 = 0, s2 = 0, max, ans = 0, s3, s4; cin >> n; vector<pair<long long, long long>> v; for (i = 0; i < n; i++) { cin >> a >> b; v.push_back(make_pair(a, b)); s1 += a; s2 += b; } max = abs(s1 - s2); s3 = s1; 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
import java.util.*; import java.io.*; import java.lang.*; public class Parade { static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.strea...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) a = [list(map(int, input().split())) for _ in range(n)] l, r = sum([x[0] for x in a]), sum([x[1] for x in a]) val = abs(l - r) ans = 0 for i, x in enumerate(a): cur = abs(l - x[0] + x[1] - r + x[1] - x[0]) if cur > val: val = cur ans = i + 1 print(ans)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, mx = 0, lsum = 0, rsum = 0, ans = 0; std::cin >> n; int l[n + 1], r[n + 1]; for (int i = 1; i <= n; i++) { std::cin >> l[i] >> r[i]; lsum += l[i]; rsum += r[i]; } mx = abs(lsum ...
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 long int n, l[222222], r[222222], mx = 0, k, q, ll, rr, ll1, rr1, ans, ans1; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; ll = ll + l[i]; rr = rr + r[i]; } k = ll - rr; for (int ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
//package que_a; import java.io.*; import java.util.*; import java.math.*; public class utkarsh { InputStream is; PrintWriter out; long mod = (long) (1e9 + 7), inf = (long) (3e18); void solve() { int n = ni(); long l = 0, r = 0; int al[] = new int[n]; int ar[...
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 scanner.MyScanner ; import java.io.BufferedReader ; import java.io.IOException ; import java.io.InputStreamReader ; import java.util.* ; //https://codeforces.com/contest/733/problem/B public class Main { public static void main(String[] args) { MyScanner sc = new MyScanner() ; ...
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 = 1e5 + 5; int l[maxn], r[maxn], a[maxn]; int cmp(int a, int b) { return a < b; } int main() { int n, L = 0, R = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &l[i], &r[i]); L += l[i]; R += r[i]; } int index, max1 = ab...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class CF733B { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long l=0,r=0; int [] a = new int[n]; int [] b = new int[n]; for (int i = 0; i < n; i++) { int y=in.nextInt(...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.*; public class Cheker{ static class Pair{ int val; int index; Pair(int v,int index){ this.val=v; this.index=index; } } public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int l=0; int r=0; int[][] A=new int[n][2]; LinkedList<Pair...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int l[N], r[N]; int main() { int n, L, R; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d%d", l + i, r + i), L += l[i], R += r[i]; int Max = abs(L - R), ans = 0; for (int i = 1; i <= n; i++) { if (abs(L + r[i] - l[i] - (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()) a = [] lsum = 0; rsum = 0; i = 0; while(i < n): l, r = map(int, input().split()) a.append((l, r)) lsum += l rsum += r i += 1 ans = 0 cur = abs(lsum - rsum) i = 0; while(i < n): lsum -= a[i][0] rsum -= a[i][1] lsum += a[i][1] rsum += a[i][0] if(cur < abs(lsu...
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()) s = [] for _ in range(n): l, r = map(int, input().split()) s.append(l - r) osm = sum(s) mx = osm ans = 0 for i in range(n): if abs(osm - 2 * s[i]) > abs(mx): mx = osm - 2 * s[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
import java.io.PrintWriter; import java.util.ArrayList; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class CF_733B { public static void main(String[] args) { new CF_733B().run(); } public void ru...
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
value = 0 va = 0 clist=[] blist=[] for i in range(int(input())): a= input().split() b=int(a[0]) c=int(a[1]) blist.append(b) clist.append(c) maxb = sum(blist) maxc = sum(clist) for i in range(len(blist)): b=blist[i] c=clist[i] if abs((maxb-b+c)-(maxc-c+b)) > value and abs((maxb-b+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
a=[] b=[] sum1=0 sum2=0 maxsum=0 k=0 for i in range(int(input())): x, y=map(int, input().split()) a.append(x) b.append(y) sum1+=x sum2+=y maxsum=abs(sum1-sum2) for i in range(len(a)): sum1=sum1-a[i]+b[i] sum2=sum2-b[i]+a[i] # print (abs(sum1-sum2), maxsum) if (abs(sum1-sum2)>maxsum): k=i+1 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
import java.util.Scanner; public class _0925Parade { int l; int r; public _0925Parade(int l,int r) { this.l=l; this.r=r; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int L=0; int R=0; _0925Parade[] arr = new _0925Parade[n]; int maxK=0; ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int n = cin.nextInt(); int[] a = new int[100010]; int[] b = new int[100010]; long left = 0; long right = 0 ; for(int i=0;i<n;i++) { a[i] = cin.nextInt(); b[i] = cin.nextInt(...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#!/usr/bin/env python3 def main(): try: while True: n = int(input()) left = [0] * n right = [0] * n for i in range(n): left[i], right[i] = map(int, input().split()) ls = sum(left) rs = sum(right) best = abs...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(raw_input()) l,r = 0,0 mi1 = -12454 mi2 = -123456 for i in xrange(n): a,b = map(int, raw_input().split()) l+=a r+=b if b-a>mi1: mi1 = b-a val1 = b val2 = a flag1 = i+1 if a-b>mi2: mi2 = a-b val3 = a val4 = b flag2 = i+1 p,q,r = abs(l-r), abs(l+val1-val2-r-val2+val1), abs(l+val4-val3-r-val3+...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class B { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.next...
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.*; import java.io.IOException; import java.io.InputStream; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { File file = new File("in.txt"); Input...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(raw_input()) t1=[] t2=[] sum1=0 sum2=0 for i in range(n): a,b=map(int,raw_input().split()) t1.append(a) t2.append(b) sum1+=a sum2+=b tmp=abs(sum1-sum2) res=0 for i in range(n): t= abs((sum1-t1[i]+t2[i]) - (sum2-t2[i]+t1[i])) if t > tmp: res=i+1 tmp=t print res
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
def main(): n = input() left = [] right = [] sumleft = 0 sumright = 0 for i in range(n) : lr = [int(j) for j in raw_input().split()] left.append(lr[0]) right.append(lr[1]) sumleft += lr[0] sumright += lr[1] ret = abs(sumleft-sumright) ans = 0 for i in range(n): if ret < abs((sumleft-left[i]+right[i...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(raw_input()) s = 0 r = [] for i in range(n): li, ri = map(int, raw_input().split()) s += li - ri r.append(li - ri) ma = abs(s) mi = 0 for i, ri in enumerate(r, 1): t = abs(s - 2*ri) if t > ma: ma = t mi = i print mi
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(raw_input()) deltas = [] s = 0 for i in range(n): li, ri = map(int, raw_input().split()) deltas.append(li - ri) s += (li - ri) res, maxb = -1, abs(s) for i in range(n): candi = s - 2 * deltas[i] if maxb < abs(candi): maxb = abs(candi) res = i + 1 if res == -1: print 0 e...
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
x = int(input()) t = 0 t1 = 0 k = 0 k1 = 0 i = 0 r = 0 r1 = 0 for i in range(1,x+1): a = list(map(int,input().split())) t = t + a[0] k = max(a[0]-a[1],k) if k == a[0] - a[1]: r = i t1 = t1 + a[1] k1 = max(a[1]-a[0],k1) if k1 == a[1] - a[0]: r1 = i if t + k1 > t1 + k: print(r1) else: print(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 sys # sys.stdin = open('input.txt','r') # sys.stdout = open('output.txt','w') input = lambda:sys.stdin.readline().strip() li = lambda:list(map(int,input().split())) I = lambda: int(input()) n = I() nl=[] for i in range(n): nl.append(li()) s=[0,0] for i in nl: s[0]+=i[0] s[1]+=i[1] m = abs(s[0]-s[1]) ans = -1...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) L = [0] R = [0] for _ in range(1,n+1): x, y = map(int, input().split()) L.append(x) R.append(y) maxk = 0 sL, sR = sum(L), sum(R) maxb = abs(sL-sR) for k in range(1,n+1): b = abs(sL-sR-2*L[k]+2*R[k]) if b>maxb: maxk, maxb = k, b print(maxk)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; long long Rnumbs, Lnumbs; int L[100001], R[100001]; int n; bool loop() { Lnumbs = 0; Rnumbs = 0; for (int i = 1; i <= n; i++) { cin >> L[i] >> R[i]; Lnumbs += L[i]; Rnumbs += R[i]; } int k = 0; long long maxs = abs(Lnumbs - Rnumbs); for (int i = 1;...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#!/usr/bin/env python3 from sys import stdin def main(): n, = stdin_get_ints_from_line() pairs = [] total_l = 0 total_r = 0 for i in range(n): l, r = stdin_get_ints_from_line() total_l += l total_r += r pairs.append((l, r)) max_beauty_val = abs(total_l - to...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.util.*; public class Codeforces { public static void main(String[] args) { InputReader in=new InputReader(System.in); OutputWriter out=new OutputWriter(System.out); int n=in.nextInt(); int l=0,r=0; int pa[][]=new int[n][2]; for (int i=0;i<n;i++) { pa[i][0]=in.nextInt()...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = input() left = [] right = [] for i in range(n): l, r = map(int, raw_input().split()) left.append(l) right.append(r) totalLeft = sum(left) totalRight = sum(right) maxBeauty = abs(totalLeft - totalRight) col = 0 for i in range(n): flipL = totalLeft - left[i] + right[i] flipR = totalRight - right[i] + left[i...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) l = list(map(lambda x: tuple(map(int, input().split())), range(n))) p, q = map(sum, zip(*l)) o = abs(p - q) a, ai = o, 0 for i in range(n): u, v = l[i] p += v - u q += u - v if abs(p - q) > a: a, ai = abs(p - q), i + 1 p -= v - u q -= u - v print(ai)
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()) larr=[] rarr=[] for i in range(n): yo=list(map(int,input().split())) larr.append(yo[0]) rarr.append(yo[1]) l=sum(larr) r=sum(rarr) maxb=abs(l-r) ans=-1 #print() for i in range(n): ro=abs((l-larr[i]+rarr[i])-(r-rarr[i]+larr[i])) #print(ro,maxb) if ro>maxb: ans=i maxb=ro print(ans+1)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) l=[] le,ri=0,0 for i in range(n): a,b=map(int,input().split()) le+=a ri+=b l.append([a,b]) ma=le-ri z=[] t=ma for i in range(n): t=t-2*l[i][0]+2*l[i][1] z.append(abs(t)) t=ma if max(z)>abs(ma): print(z.index(max(z))+1) else: print(0)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
//Author: net12k44 import java.io.*; import java.util.*; //public class Main{//} private void solve() { int n = in.nextInt(); int[] l = new int[n], r = new int[n]; int L = 0, R = 0; for(int i = 0; i < n; ++i){ l[i] = in.nextInt(); r[i] = in.nextInt(); L += l[i]; R += r[i]; } int result = -1; int be...
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=0 R=0 t=[[0,0] for i in range(n)] for i in range(n): a,b=map(int,input().split()) L+=a R+=b t[i][0]=a t[i][1]=b maxx=abs(L-R) ind=0 for i in range(n): j=t[i][0] k=t[i][1] B=abs((L-j+k)-(R-k+j)) if B>maxx: maxx=B 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()) l = [] r = [] L, R = 0, 0 for i in range(n): x, y = map(int, input().split()) l.append(x) r.append(y) L += x R += y now = abs(L-R) res = 0 for i in range(n): x = L y = R x -= l[i]; x += r[i]; y -= r[i]; y += l[i]; if (abs(x-y) > now): now = abs(x-y) res = i+1 print(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
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { FastScanner in; PrintWriter out; static final String FILE = ""; void solve() { int n = in.nextInt(); int[] as = new int[n]; int[] bs = new int[n]; int a = 0, b = 0; 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
import java.util.*; 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]; int L = 0; int R = 0; int max_diff = 0; for (int i = 0; i < 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()) a = [0] * n R = 0 L = 0 for i in range(n): a[i] = list(map(int, input().split())) R += a[i][1] L += a[i][0] m = abs(L - R) ans = 0 for i in range(n): b = abs((L - a[i][0] + a[i][1]) - (R - a[i][1] + a[i][0])) if b > m: ans = i + 1 m = b print(ans)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(raw_input()) a=[] l=r=ans=chk=0 p,q=[0]*3,[0]*3 for i in range(n): x,y=map(int,raw_input().split()) l,r=l+x,r+y if x>y: if x-y>p[0]-p[1]: p=[x,y,i+1] if x<y: if y-x>q[1]-q[0]: q=[x,y,i+1] # a.append((x,y)) ll=abs((l-q[0]+q[1])-(r-q[1]+q[0])) rr=abs((l-p[0...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; const int NMAX = 1000000; long long L[NMAX], R[NMAX]; int main() { long long n, SL = 0, SR = 0, S = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> L[i] >> R[i]; SL += L[i]; SR += R[i]; } long long aux = abs(SL - SR); int ans = 0; for (int i = 0;...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
def readval(typ=int): return typ( raw_input() ) def readvals(typ=int): return map( typ, raw_input().split() ) def testcase(): n = readval() L, R = 0, 0 ls, rs = [], [] for i in xrange(n): l, r = readvals() L += l; R += r ls.append(l); rs.append(r) beau = abs(L-R) ...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> int main() { int n, b, k, l, m, g, sumx = 0, sumy = 0, x = 0, y = 0, suth = 0, j = 0; scanf("%d", &n); int arr[n][2]; for (int i = 1; i <= n; i++) { scanf("%d %d", &arr[i][0], &arr[i][1]); sumx += arr[i][0]; sumy += arr[i][1]; if (arr[i][0] - arr[i][1] > x) { x = a...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n, lsum = 0, l[100000], r[100000], rsum = 0, diffmax = INT_MIN, flag, ind, i; cin >> n; for (i = 0; i < n; i++) { cin >> l[i] >> r[i]; lsum = lsum + l[i]; rsum = rsum + r[i]; } diffmax = abs(lsum - rsum); ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n, left[100000], right[100000], left_sum = 0, right_sum = 0, index, temp = -1; cin >> n; for (int i = 0; i < n; i++) { cin >> left[i] >> right[i]; left_sum += left[i]; right_sum += ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) l, r = 0, 0 dif = [] res = 0 for i in range(n): x, y = map(int, input().split()) dif.append(x - y) l = l + x r = r + y a = l - r c = a for i in range(n): b =a - 2 * dif[i] if abs(b) > abs(c): res = i + 1 c = b print(res)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; long long a, b[100880], c[108800], d[5888888], e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm, nn, oo, pp, qq, rr, ss, tt, uu, vv, ww, xx, yy, zz; int main() { cin >> n; for (int i = 0; i < n;...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) l, r = 0, 0 a = [] for i in range(n): l_i, r_i = map(int, input().split()) l += l_i r += r_i a.append([l_i, r_i]) ans = 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])) > ans): ans = abs(l - a[i][0] + a[i][1] - (r - a[i][1] + 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
diff1 = int(0) diff2 = int(0) pos1 = int(0) pos2 = int(0) current = int(0) for i in range(int(input())): x, y = map(int, input().split()) if y - x > diff1: pos1 = i + 1 diff1 = y- x if x - y > diff2: pos2 = i + 1 diff2 = x - y current += x - y print(pos1 if abs(current + 2 * diff1) > abs(current - 2 * dif...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
def switch(a,b): x = [a[j] - b[j] for j in range(len(a))] #print sum(x) i1 = x.index(max(x)) i2 = x.index(min(x)) m = abs(sum(x)) idx = 0 s1 = abs(sum(x)-2*min(x)) s2 = abs(sum(x)-2*max(x)) if m < max(s1,s2): if s1>s2: idx = i2+1 else: idx = i1+1 return idx n = int(raw_input()) l = list() r = list(...
PYTHON
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n=int(input()) l=[0]*n r=[0]*n L=0 R=0 for i in range(n): a,b=map(int,input().split()) l[i]=a L+=a r[i]=b R+=b Mx=abs(R-L) j=0 for i in range(n): if abs((R-r[i]+l[i])-(L-l[i]+r[i]))>Mx: Mx=abs((R-r[i]+l[i])-(L-l[i]+r[i])) j=i+1 print(j)
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
n = int(input()) left = [] right = [] for i in range(n): a, b = map(int, input().split()) left.append(a) right.append(b) l = sum(left) r = sum(right) beauty = abs(l - r) row = 0 for i in range(n): l = l - left[i] + right[i] r = r - right[i] + left[i] tmp = abs(l - r) if tmp > beauty: row = i + 1 beauty =...
PYTHON3
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
sl = 0 sr = 0 d = [] n = int(input()) for i in range(n): l,r = map(int,input().split()) sl+=l sr+=r d.append([l-r,i+1]) d.sort() md = sl-sr ans = 0 ad = abs(md) if abs(md-d[0][0]*2)>ad: ans = d[0][1] ad = abs(md-d[0][0]*2) if abs(md-d[-1][0]*2)>ad: ans = d[-1][1] ad = abs(md-d[-1][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
#include <bits/stdc++.h> using namespace std; bool sizes(string a, string b) { return a.size() < b.size(); } int main() { ios::sync_with_stdio(0); cin.tie(0); long long n = 0, m = 0, mn = 1000000000007, d = 0, mx = 0, h = 0, l = 0, w = 0, r = 0, k = 0, j = 0, i = 0, ans; cin >> n; vector<int> 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
#================================= # Author: Danish Amin # Date: Wed Oct 28 01:50:14 2020 #================================= # from debug import * import sys; input = sys.stdin.readline inf = int(1e10) n = int(input()) a = [] b = [] for i in range(n): x, y = map(int, input().split()) a.append(x); b.append(y) d = [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
#include <bits/stdc++.h> using namespace std; int arr[100005]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, l, r; while (cin >> n) { int L = 0, R = 0; for (int i = 0; i < n; i++) { cin >> l >> r; arr[i] = r - l; L += l, R += r; } int* mn = min_element(arr, arr + n);...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
import java.io.*; import java.util.StringTokenizer; public class CF0733B { static BufferedReader sIn = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] dieParade) throws IOException { int n = Integer.parseInt(sIn.readLine()); int l = 0; int r = 0; int ilr = 0; int irl ...
JAVA
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; long long int left = 0, right = 0; int part1[n], part2[n], row = 0; for (int i = 0; i < n; i++) { cin >> part1[i] >> part2[i]; left += part1[i]; right += part2[i]; } long long int ma...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; long long i, j, k, n, m, a1, a2, ans, x, y, wz; struct node { long long l, r; } a[1000100]; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> a[i].l >> a[i].r, a1 += a[i].l, a2 += a[i].r; ans = abs(a1 - a2); k = ans; for (i = 1; i <= n; i++) { x = a1 - ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> L(n), R(n); int r = 0, l = 0; for (int i = 0; i < n; i++) { cin >> L[i] >> R[i]; r += R[i]; l += L[i]; } int ans = -1; int mx = abs(l - r); for (int i = 0; i < n; i++) { int ll = l - L[i] + R[i]; ...
CPP
733_B. Parade
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg...
2
8
#include <bits/stdc++.h> int main() { long n; scanf("%ld", &n); std::vector<long> diff(n, 0); long left(0), right(0); for (int p = 0; p < n; p++) { long a, b; scanf("%ld %ld", &a, &b); diff[p] = 2 * (a - b); left += a; right += b; } long init(left - right); long col(0); long maxDif...
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; /* ========== ========== ========== */ // Author - Vamsi Sangam // /* ========== ========== ========== */ /* ========== About Parade.java ========== ========== ========== ========== ========== */ public class Parade { public static void main(String[] args) { Scan...
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=[] for i in range(n): a,b=map(int,input().split()) l.append([a,b]) left=0 right=0 for i in range(n): left+=l[i][0] right+=l[i][1] maxdiff=abs(left-right) a=0 for i in range(n): k=abs((left+l[i][1]-l[i][0])-(right+l[i][0]-l[i][1])) if k>maxdiff: maxdiff=k index=i+...
PYTHON3