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(input())
l = [0 for i in range(n)]
r = [0 for i in range(n)]
leftSumm = 0
rightSumm = 0
for i in range(n):
l[i], r[i] = list(map(int, input().split()))
leftSumm += l[i]
rightSumm += r[i]
result = -1
maxresult = abs(leftSumm - rightSumm)
for i in range(n):
tempLeft = leftSumm - l[i] + r[i]
t... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import sys
n = int(input())
a = [0]*(n+1)
for i in range(n):
l, r = map(int, sys.stdin.readline().split())
a[i+1] = l-r
a[0] += l-r
a[1:] = [a[0]-2*a[i] for i in range(1,n+1)]
a2 = [abs(i) for i in a]
ma2 = max(a2)
idx = a2.index(ma2)
print(idx)
| 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 _ in range(n):
l_, r_ = list(map(int, input().split()))
l.append(l_)
r.append(r_)
L = sum(l)
R = sum(r)
mx = abs(L-R)
sol = -1
for i in range(n):
mxt = abs(L-R-2*l[i]+2*r[i])
if mxt > mx:
mx = mxt
sol = i
if sol == -1:
print(0)
else:
print(s... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import sys
n = int(sys.stdin.readline())
mp = [None] * n
l = r = 0
for i in range(n):
mp[i] = list(map(int, sys.stdin.readline().split()))
l += mp[i][0]
r += mp[i][1]
dif = abs(l-r)
res = int(0)
for i in range(n):
_l = l - mp[i][0] + mp[i][1]
_r = r - mp[i][1] + mp[i][0]
_dif = abs(_l-_... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
a = []
ans = 0
L,R = 0,0
for i in range(n):
t = input().split()
L += int(t[0])
R += int(t[1])
a.append(t)
Max = abs(L-R)
for i in range(n):
l = L - int(a[i][0]) + int(a[i][1])
r = R - int(a[i][1]) + int(a[i][0])
if abs(l-r) > Max:
Max = abs(l-r)
ans = i+1
pri... | 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: Mo Abjal, MJP Rohilkhand University Bareilly, UP, India 2018.
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////********************//////////////////////////////
/////////////////////////////* SOLUTION *//////////////////////////////
////////... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args) throws Exception {
FastScanner in = new FastScanner();
int n = in.nextInt();
int a[][] = new int[n][2];
... | 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 = []
sum_l = 0
sum_r = 0
for i in range(n):
l, r = map(int, input().split())
L.append((l, r))
sum_l += l
sum_r += r
krasa = abs(sum_l - sum_r)
ans = 0
for i in range(n):
if abs((sum_l - L[i][0] + L[i][1]) - (sum_r - L[i][1] + L[i][0])) > krasa:
krasa = abs((sum_l - L[i][0]... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
left = []
right = []
for i in range(n):
l, r = map(int, input().split())
left.append(l)
right.append(r)
x = sum(left)
y = sum(right)
k = 0
t = 0
for i in range(n):
p = left[i]
q = right[i]
if(abs(x-y+2*(q-p)) > abs(x-y)) and (abs(x-y+2*(q-p)) - abs(x-y) > t):
t = abs(x-y... | 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 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 31 20:00:41 2016
@author: Chandak
"""
'''
r = lambda : map(int, raw_input().split())
t = r()[0]
fir, sec = [], []
max_dif = float('-inf')
dif_ind = 0
first_sum, sec_sum = 0, 0
for x in xrange(t):
n, m = r()
if abs(n-m) > max_dif :
max_dif = abs(n-m)
... | PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long N = 1e5 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;
long long n;
long long r, l;
long long cnt, ans, pos;
int main() {
ios_base::sync_with_stdio(0);
cin >> n;
long long arr[n], b[n];
for (int i = 0; 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 static java.lang.System.exit;
import java.io.*;
import java.util.*;
import java.util.stream.IntStream;
public class Main {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
static int nextInt() throws IOException {
return Integer.parseInt(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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args)throws Throwable {
MyScanner sc=new MyScanner();
PrintWriter pw=new PrintWriter(System.out,true);
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 |
n = int(input())
#n, m = map(int, input().split())
#s = input()
#c = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
a[i], b[i] = map(int, input().split())
k = sum(a)
m = sum(b)
l = abs(k - m)
x = 0
s = 0
for i in range(n):
if s < abs(k - m - a[i] * 2 + b[i] * 2) - l:
x = i +... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.util.*;
import java.math.*;
import java.io.*;
import java.text.DecimalFormat;
import java.math.BigInteger;
public class Main{
//static int d=20;
static long mod=1000000007 ;
static long mod3=1000000009 ;
static long mod2=mod-1;
//static HashMa... | 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 | c = [(0, 0)] + [list(map(int, input().split())) for _ in range(int(input()))]
d = list(zip(*c))
L = sum(d[0])
R = sum(d[1])
ans = [abs(L - R - (x[0] - x[1]) * 2) for i, x in enumerate(c, 1)]
print(ans.index(max(ans)))
| PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | from sys import stdin as fin
# fin = open("cfr378b.in")
n = int(fin.readline())
# k, r = map(int, fin.readline().split())
# line = tuple(fin.readline().strip())
# line = fin.readline().strip()
# cols = (tuple(map(int, fin.readline().strip().split())) for i in range(n))
l, r = [None] * n, [None] * n
ls = rs = 0
for i i... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #!/usr/bin/python2
# -*- coding: utf-8 -*-
import sys
import os
def main():
N = int(sys.stdin.readline())
LR = [None] * N
sl = sr = 0
for i in xrange(N):
LR[i] = map(int, sys.stdin.readline().split())
sl += LR[i][0]
sr += LR[i][1]
best = abs(sl - sr)
besti = 0
for 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())
a,b=[],[]
resa,resb=0,0
# tempa,tempb=0,0
result,j=0,0
for i in range(n):
k,l=map(int,raw_input().split())
a.append(k)
b.append(l)
resa+=k
resb+=l
for i in range(n):
tempa=resa
tempb=resb
tempa=tempa-a[i]+b[i]
tempb=tempb-b[i]+a[i]
if abs(tempa-tempb)>abs(resa-resb) and abs(tempa-tempb)>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 | num = int(input())
lis = []
origin = 0
for _ in range(num):
inp = list(map(int, input().split()))
origin += inp[0]-inp[1]
lis.append(inp)
ma = abs(origin)
ma_index = 0
for i in range(num):
tmp = lis[i][1]-lis[i][0]
su = abs(origin-(lis[i][0]-lis[i][1])+tmp)
if su > ma:
ma = su
ma... | 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 f(n, s):
L = 0
R = 0
for (a,b) in s:
L += a
R += b
beauty = abs(L-R)
ind = -1
for i in range(n):
(a,b) = s[i]
new = abs((L-a+b) - (R-b+a))
if new > beauty:
ind = i
beauty = new
return ind+1
def run():
s = []
i... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;
public class Cprob1810 {
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 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[] dif = new int[n];
int totall = 0, totalr = 0;
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < 2 ; j++){
a[i][j] = sca... | 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 = 200001, inf = 100000000, infn = -100000000;
struct parade {
int dif, ind;
};
bool caca(parade a, parade b) {
if (a.dif < b.dif)
return true;
else
return false;
}
int n, l, r, totl, totr, tot, d, ans, pos;
parade row[MAXN];
int main() {
while... | 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 Parade
{
public static void main(String args[])
{
int n,suml=0,sumr=0;
Scanner s=new Scanner(System.in);
n=s.nextInt();
int flag=0;
int[] l=new int[n+1];
int[] r=new int[n+1];
int[] d=new int[n+1];
int[] e=new int[n+1];
int[] f=new int[n+1];
Stri... | 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 | from sys import stdin
import math
def mainB():
dif = []
n = int(stdin.readline())
for i in range(0,n):
dif.append(reduce(lambda x,y: int(x)-int(y), stdin.readline().split()))
sum = reduce(lambda x,y: x+y, dif)
max_b = abs(sum)
best = 0
for i in range(0, len(dif)):
if abs(sum - 2*dif[i]) > max_b:
max_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 | import sys
n = int(sys.stdin.readline().strip())
rows = []
for i in range(n):
row = list(map(int,sys.stdin.readline().strip().split()))
row = list(map(lambda x: x-min(row[0],row[1]),row))
rows += [row]
sumL = sum([row[0] for row in rows])
sumR = sum([row[1] for row in rows])
currBest = abs(sumL-sumR)
# print c... | 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 a, b, index = 0, maxneg = 0, maxpos = 0, maxnegi = 0, maxposi = 0,
totalpos = 0, totalneg = 0;
for (int i = 1; i <= n; i++) {
cin >> a >> b;
int diff = a - b;
if (diff > 0) {
totalpos += diff;
if ... | 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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /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 | cnt = lambda s, x: s.count(x)
ii = lambda: int(input())
si = lambda: input()
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
n=ii()
a, b=zip(*(map(int, input().split()) for _ in range(n)))
asm=sum(a)
bsm=sum(b)
c=[abs(asm-bsm)]
for i,j in zip(a,b):
c.append(abs(asm+j-i-(bsm+i-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 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int amount = scan.nextInt();
Column[] arr = new Column[amount];
int diffSum = 0;
for (int i = 0; i<amount; ++i) {
arr[i] = new Colum... | 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.text.*;
import java.math.*;
public class main {
public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter pw = new PrintWriter(System.out);
public static String line;
public static StringTokenizer ... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n;
int l[100005];
int r[100005];
int la[100005];
int ra[100005];
long long L, R;
pair<long long, int> demetrio;
int main() {
L = 0, R = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &l[i], &r[i]);
L += l[i];
R += r[i];
}
demetrio... | 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.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
public class B {
public static void main(String[] args) {
FastScannerB sc = new FastScannerB(System.in);
int N = sc.nextInt();
int[] left = new int[N];
int[] right = new int[N];
int sumL = 0;
int sumR = 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 | #include <bits/stdc++.h>
const int INF = 1 << 29;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
;
long long n;
std::cin >> n;
std::vector<int> a(n), b(n);
long long sum1 = 0, sum2 = 0;
for (long long i = 0; i < n; i++) {
long long in1, in2;
std::cin >> in1 >> in2;
a... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
diff=[x[0]-x[1] for x in a]
s=sum(diff)
num=s
res=0
for i in range(n):
if abs(s-2*diff[i])>abs(num):
res=i+1
num=s-2*diff[i]
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.util.*;
import java.io.*;
public class Main {
BufferedReader in;
PrintWriter out;
StringTokenizer str;
private String next() throws Exception {
if (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return str.nextToken();
}
private int nextInt() throws Exceptio... | 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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Jaswant Singh[joney_000][ja... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) { return (a > b) ? a : b; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n;
cin >> n;
long long int l[n], r[n], L = 0, R = 0;
for (long long 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;
const int mx = 1e5 + 10;
int ls[mx], rs[mx];
int main() {
int n;
scanf("%d", &n);
int l = 0, r = 0;
for (int i = 0; i < n; i++) {
scanf("%d %d", ls + i, rs + i);
l += ls[i];
r += rs[i];
}
int best = abs(l - r);
int idx = 0;
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())
m=[]
for i in range(n):
x=input().split()
x[0]=int(x[0])
x[1]=int(x[1])
m.append(x)
res=[]
L=0
R=0
for y in range(n):
L+=m[y][0]
R+=m[y][1]
res.append(abs(L-R))
for i in range(n):
L1=L-m[i][0]+m[i][1]
R1=R-m[i][1]+m[i][0]
res.append(abs(L1-R1))
print(res.index(max(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()
x=[]
y=[]
ll=int(0)
rr=int(0)
for i in range(0,n):
a,b=map(int,raw_input().split())
x.append(a)
y.append(b)
ll+=a
rr+=b
ans=int(0)
res=int(abs(ll-rr))
for i in range(n):
newa=int(ll-x[i]+y[i])
newb=int(rr-y[i]+x[i])
newr=int(abs(newa-newb))
if newr>res:
res=newr
ans=i+1
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 | def beauty(l,r):
return abs(l-r)
def calcBeauty(b):
l = 0
r = 0
for x in b:
l+= x[0]
r+= x[1]
return [beauty(l,r), l, r]
def calcBigest(l ,r):
return l > r
def func():
n = int(input())
b = list()
for i in range (n):
line = input()
l = line.split()
... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
left = []
right = []
R = 0
L = 0
for i in range(n):
a, b = map(int, input().split())
left.append(a)
L += a
R += b
right.append(b)
base = abs(L - R)
m = base
cur = -1
for i in range(n):
L1 = L - left[i] + right[i]
R1 = R - right[i] + left[i]
curm = abs(L1 - R1)
if cur... | 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;
/**
* @author andrey
*/
public class B {
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
final int n = scanner.nextInt();
int max = 0;
int maxNum = -1;
int min = 0;
int minNum = -1;
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;
const int N = 1e5 + 7, INF = INT_MAX;
int main() {
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> l(n), r(n);
int L = 0, R = 0;
for (int i = 0; i < n; ++i) {
cin >> l[i] >> r[i];
L += l[i];
R += r[i];
}
int ans = abs(L - R), pos =... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
L = 0
R = 0
lev =[]
prav = []
kol = 0
for i in range(n):
l, r = map(int, input().split())
L += l
R +=r
lev += [l]
prav += [r]
maxkr = (max(L, R) - min(L, R))
L1 = L
R1 = R
for i in range(len(lev)):
L -= lev[i]
R -= prav[i]
L += prav[i]
R += lev[i]
kr... | 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 the name of god
#Mr Rubick
n=int(input())
l=[0]*n
r=[0]*n
for i in range(n):
l[i],r[i]=[int(s) for s in input().split()]
sl=sum(l)
sr=sum(r)
m=abs(sl-sr)
k=0
for i in range(n):
new=abs(sl-sr+2*r[i]-2*l[i])
if new>m:
m=new
k=i+1
print(k) | 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.StringTokenizer;
public class B {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n = Integer.parseInt(br.readLine());
int[][] soldiers =... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
long long k, m1 = 0, m2 = 0, t1 = 0, t2 = 0, l1 = 0, l2 = 0, s1[t], s2[t],
o1 = 0, o2 = 0;
for (int i = 0; i < t; i++) {
cin >> s1[i] >> s2[i];
l1 = l1 + s1[i];
l2 = l2 + s2[i];
k = s1[i] - s2[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;
template <class T>
T gcd(T a, T b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
template <class T>
T power(T a, T b) {
T result = 1;
while (b > 0) {
if (b & 1) result = result * a;
a = a * a;
b >>= 1;
}
return result;
}
template <clas... | 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() {
vector<long long> left;
vector<long long> right;
long long l, r, n;
long long leftSum, rightSum;
leftSum = rightSum = 0;
cin >> n;
while (n--) {
cin >> l >> r;
leftSum += l;
rightSum += r;
left.push_back(l);
right.push_back(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())
j=k=0
s=0
a=[]
b=[]
for i in range(n):
x,y=map(int,input().split())
if x>=y:
j+=1
if y>=x:
k+=1
a.append(x)
b.append(y)
s+=(x-y)
if j==n or k==n:
print(0)
exit(0)
z=s
max=(abs(s))
for i in range(n):
s+=(2*(b[i]-a[i]))
if max<abs(s):
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 | q_number = int(raw_input(""))
bias = 0
liste = []
for i in range(q_number):
ans = raw_input("")
ans = ans.split(" ")
liste.append(int(ans[1])-int(ans[0]))
for i in liste:
bias = bias + i
minc = min(liste)
maxc = max(liste)
minbias = bias - 2 * maxc
maxbias = bias - 2 * minc
if (abs(minbias) < abs(maxbia... | 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 aa[(100000 + 5)];
int abs(int x) { return x > 0 ? x : -x; }
int main() {
int n;
while (~scanf("%d", &n)) {
int x, y, tmp;
int sum = 0, pos = -1;
for (int i = 0; i < n; i++)
scanf("%d%d", &x, &y), sum += x - y, aa[i] = x - y;
tmp = abs(sum);
for (int i = 0; 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=[0]*n
r=[0]*n
sl=sr=0
for i in range(n):
l[i],r[i]=[int(s) for s in input().split()]
sl+=l[i]
sr+=r[i]
m=abs(sl-sr)
k=0
for i in range(n):
new=abs(sl-sr+2*r[i]-2*l[i])
if new>m:
m=new
k=i+1
print(k) | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(raw_input())
L = 0
R = 0
a = []
for i in range(n):
l,r = map(int,raw_input().split(' '))
R += r
L += l
a.append(r-l)
maxv = abs(L-R)
maxp = 0
for i in range(n):
if abs(L-R+2*a[i])>maxv:
maxv=abs(L-R+2*a[i])
maxp=i+1
print maxp
| PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.util.Scanner;
public class JavaApplication25 {
public static int f(int x)
{
if(x<0)
return (-1)*x;
return x;
}
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int t=0;
int n=sc.nextInt();
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())
a=[]
l,r=0,0
b=0
c=-1
for i in range(n):
a.append([int(x) for x in input().split()])
l,r=l+a[i][0],r+a[i][1]
b=abs(l-r)
for i in range(n):
d=abs((l-a[i][0]+a[i][1])-(r-a[i][1]+a[i][0]))
if d>b:
b=d
c=i
print(c+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.math.BigInteger;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;
import static java.lang.Math.abs;
import static java.lang.Math.min;
public class Keks {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = 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 | #include <bits/stdc++.h>
using namespace std;
long long L = 0, R = 0;
long long l[100005], r[100005];
long long Beauty(long long l, long long r) {
return abs(L - R - 2 * l + 2 * r);
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> l[i] >> r[i];
L += l[i];
R += r[i];
}
int res... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int n;
int rows[N][2];
int L = 0;
int R = 0;
int main() {
scanf("%d\n", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d\n", &rows[i][0], &rows[i][1]);
L += rows[i][0];
R += rows[i][1];
}
int beauty = abs(L - R);
int maxBeauty = be... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n;
int l[100010];
int r[100010];
int main() {
while (cin >> n) {
int suml = 0, sumr = 0;
for (int i = 1; i <= n; i++) {
cin >> l[i] >> r[i];
suml += l[i];
sumr += r[i];
}
int result = 0;
int cur = abs(suml - sumr);
for (int i ... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 |
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 | s=int(input())
temp1=[]
temp2=[]
suma=[]
suma2=[]
total1=0
total2=0
lado=0
rango=int(s)
def sumarLista(lista):
a=0
for i in range(0,len(lista)):
a=a+int(lista[i])
return a
for i in range(0,rango):
if(i < rango):
num=input()
num=num.split(" ")
temp1.insert(i,num[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 | import java.util.*;
public class comp{
static int mode(int x){
if(x<0){
x=-x;
}
return x;
}
public static void main(String[] args) {
int n,i,j=500,k=0,l=0,r=0,x=-1,y=-1,b,s1=0,s2=0,s0;
Scanner scan=new Scanner(System.in);
n=scan.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 | #include <bits/stdc++.h>
using namespace std;
void comeon() {
long long int n;
cin >> n;
vector<pair<int, int>> parade(n);
for (int i = 0; i < n; i++) {
cin >> parade[i].first >> parade[i].second;
}
long long int left = 0, right = 0;
for (auto col : parade) left += col.first, right += col.second;
lo... | 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.*;
public class fun{
public static void main(String ar[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int sum1=0,sum2=0,f=0,max1=0,max2=0;
ArrayList<Integer> l=new ArrayList();
ArrayList<Integer> r=new ArrayList();
for(int i=0;i<n;i++){
l.add(sc.nextInt());
sum1+=l.get(i);
r.add... | 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.Arrays;
public class Main {
private static myScanner sc;
private static PrintWriter pw;
private static final int numberOfTests = 1;
private static final String nameOfInAndOutFile = "";
private static final String fullNameInputFile = nameOfInAndOutFile + ".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.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
public class Parad {
public static int[] getArray(int size) {
int[] array = new int[size];
for (int i = 0; i < size; ... | 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())
data = []
cnt_l = 0
cnt_r = 0
for i in range(n):
l, r = [int(x) for x in input().split()]
data.append([l,r])
cnt_l += l
cnt_r += r
beauty = abs(cnt_l - cnt_r)
col_n = -1
max_beauty = beauty
for i in range(n):
if abs(cnt_l - data[i][0] + data[i][1] - cnt_r + data[i][1] - data[i][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 | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class B {
public static void main(String[] args) {
try (Scanner s = new Scanner(System.in)) {
final int n = s.nextInt();
int total = 0;
final List<int[]> columns = new ArrayList<>(n);
for (int i = 0; i < n; ++i) {
... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n=int(input())
L=[]
R=[]
for _ in range(n):
a,b=map(int,input().split())
L.append(a)
R.append(b)
Lb=sum(L)
Rb=sum(R)
ind=-1
beauty=abs(Rb-Lb)
for i in range(n):
if abs((Lb-L[i]+R[i])-(Rb-R[i]+L[i]))>beauty:
beauty= abs(Lb-L[i]+R[i]-(Rb-R[i]+L[i]))
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=input(); l=0; r=0; d=[]
for t in range(n):
a,b=map(int, raw_input().split())
l+=a; r+=b
d.append(b-a)
c=min(d); v=max(d)
if c*v>0:
print 0
else:
if l>r:
if l-r+v>=abs(l-r-2*abs(c)):
print d.index(v)+1
else:
print d.index(c)+1
elif r>l:
if r-l+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 | import math
import sys
n = int(input())
v = []
leftsum = 0
rightsum = 0
for i in range(n):
v.append([int(x) for x in input().split(" ")])
leftsum+=v[i][0]
rightsum+=v[i][1]
Max = abs(leftsum-rightsum)
index = 0
for i in range(n):
curr = abs(leftsum-v[i][0]+v[i][1] - (rightsum-v[i][1]+v[i][0]))
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.Scanner;
public class Parade733B {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] l = new int[n];
int[] r = new int[n];
int left_sum = 0;
int right_sum = 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 | 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 |
n = int(input())
l = []
r = []
for i in range(n):
x , y = map(int,input().split())
l.append(x)
r.append(y)
r1 = sum(l)
r2 = sum(r)
v = abs(r1 - r2)
s = 0
for i in range(n):
k = abs(r1 - l[i] + r[i] - (r2 - r[i] + l[i]))
if k > v :
v = k
s = i + 1
print(s) | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Sol_733B {
static Scanner sc = new Scanner(System.in);
static int i(){
return sc.nextInt();
}
static String s(){
return sc.nextLine();
}
static int[] ia(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 | N = int(input())
lister = [0]*N
total = 0
miny = 0
maxy = 0
maxi = 0
mini = 0
for x in range(N):
a,b = (int(a) for a in input().split())
lister[x] = a - b
total += a - b
if miny > a - b:
miny = a - b
mini = x+1
if maxy < a - b:
maxy = a - b
maxi = x+1
maxtotal = abs(total)
bestind = 0
T = abs(total - 2*ma... | 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())
mxld = 0
mxli= -1
mxrd = 0
mxri= -1
sml = 0
smr = 0
for n in range(1, N+1):
l,r = [int(n) for n in input().split()]
diff = r - l
if(diff > mxrd):
mxrd = diff
mxri = n
if(diff < mxld):
mxld = diff
mxli = n
sml += l
smr += r
mxdiff = abs(sml - smr)
i = 0
if mxrd > 0:
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 | n=int(input())
minusas=0
minuso_k=0
pliusas=0
pliuso_k=0
suma=0
for i in range(n):
k,l=map(int,input().split())
t=k-l
if t<minusas:
minusas=t
minuso_k=i+1
elif t>pliusas:
pliusas=t
pliuso_k=i+1
suma+=k-l
if abs(suma-2*pliusas)>abs(suma-2*minusas):
print(pliuso_k)
else:
print(minuso_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 | //package main;
import java.io.*;
import java.util.*;
public class Main {
public void solve( ) throws Throwable {
int n=in.nextInt();
int[][] a=new int[n][3];
int l=0, r=0;
for(int i=0;i<n;i++){
a[i][0]=in.nextInt(); a[i][1]=in.nextInt();
l+=a[i][0]; r+=a[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 | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Tas... | 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 abso(int n) {
if (n >= 0)
return n;
else
return -1 * n;
}
int main() {
int n;
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
int arr[n][2];
for (int i = 0; i < n; i++) {
cin >> arr[i][0] >> arr[i][1];
}
int currl = 0, currr = 0;
for... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
public class A378{
void solve()
{
int n = ni();
int[] l = new int[n];
int L = 0;
int[] r = new int[n];
int R = 0;
for(int i=0;i<n;i++)
{
l[i] = ni();
L+=l[i];
r[i] = ni();
R+=r[i];
}
int k=... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | '''input
3
6 5
9 8
3 10
'''
n = int(input())
x = []
for _ in range(n):
i = list(map(int, input().split()))
x.append(i[0]-i[1])
if all(i >= 0 for i in x) or all(i <= 0 for i in x):
print(0)
else:
m = [a for a in x if a > 0]
n = [b for b in x if b < 0]
# print(x)
# print(m, n)
if len(n) == 1:
print(x.index(n[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 |
import java.util.*;
public class Java18
{
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
int columns = kbd.nextInt();
Column[] parade = new Column[columns + 1];
int totalLeft = 0;
int totalRight = 0;
for(int i = 1; i <= columns; i++) {
int left = kbd.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 sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
f... | 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 k, n, ans, l[100001], r[100001], suml, sumr;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> l[i] >> r[i];
suml += l[i];
sumr += r[i];
}
ans = abs(suml - sumr);
for (int i = 1; i <= n; i++) {
suml = suml - l[i] + r[i];
sumr = 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())
bestl = 0
bestr = 0
bestsc = -1
besti = 0
l = [0]*n
r = [0]*n
for i in range(n):
l[i],r[i] = map(int,input().split())
bestl+=l[i]
bestr+=r[i]
bestsc = abs(bestl-bestr)
for i in range(n):
bestl-=l[i]
bestl+=r[i]
bestr-=r[i]
bestr+=l[i]
if abs(bestl-bestr)>bestsc:
... | 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.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
int[] b... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 |
/**
* @author kunal05
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Template {
public static void main(String[] args) {
InputReader in = new InputReader();
PrintWriter out = new PrintWr... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.util.Scanner;
public class CF {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] l = new int[n];
int[] r = new int[n];
int suml=0,sumr=0,prev = 0, alt = 0,maxDiff = 0;
int result = 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 |
import java.awt.*;
import java.io.*;
import java.util.*;
public class Main {
static Main.MyScanner sc = new Main.MyScanner();
static PrintWriter out = new PrintWriter(System.out);
// static PrintStream out = System.out;
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 | def main():
N = int(raw_input())
L = 0
R = 0
lis = list()
ris = list()
for i in range(1, N + 1):
inp = raw_input()
li, ri = (int(s) for s in inp.split())
lis.append( li )
ris.append( ri )
L = L + lis[i-1]
R = R + ris[i-1]
B = 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 | """
"""
n = input()
z1 = [map(int, raw_input().split()) for i1 in xrange(n)]
z1 = zip(*z1)
s1 = sum(z1[0])
s2 = sum(z1[1])
a1 = abs(s1 - s2)
a2 = -1
for i1 in xrange(n):
b1 = s1 - z1[0][i1] + z1[1][i1]
b2 = s2 - z1[1][i1] + z1[0][i1]
b3 = abs(b1-b2)
if b3 >a1:
a1 = b3
a2 = i1
pri... | PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import sys
from math import*
input=sys.stdin.buffer.readline
t=int(input())
max_r=0
max_l=0
total_r=0
total_l=0
col_pos1=0
col_pos2=0
for i in range(t):
l,r=map(int,input().split())
total_l+=l
total_r+=r
if l<r:
if max_r<(r-l):
max_r=r-l
col_pos2=i+1
else:
if max_l<(l-r):
max_l=l-r
col_pos1=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 | import java.util.Scanner;
public class Parade {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int li[] = new int[n];
int ri[] = new int[n];
int L = 0,R = 0;
int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
l = []
r = []
for i in range(n):
li, ri = map(int, input().split(' '))
l.append(li)
r.append(ri)
L = sum(l)
R = sum(r)
beauty = abs(L - R)
best = -1
for i in range(n):
LL = L - l[i] + r[i]
RR = R - r[i] + l[i]
pos_beauty = abs(LL - RR)
if pos_beau... | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.