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 |
|---|---|---|---|---|---|
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int INF = 2034567891;
const long long int INF64 = 1234567890123456789ll;
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
;
long long int x, y, a, b, c;
cin >> x >> y;
... | CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.io.*;
import java.util.*;
public class No712C {
public static void main (String [] args) throws IOException {
No712C program = new No712C();
program.solve();
}
int x;
int y;
public void solve() throws IOException {
/*Scanner sc = null;
try {
sc = new Scanner(new F... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.util.Arrays;
import java.util.Scanner;
public class MemoryDevolution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
int y = scan.nextInt();
int[] arr = new int[3];
for(int i = 0; i < 3; i++){
arr[i] = y;
}
int count = 0;
while(... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
while (scanf("%d%d", &n, &m) == 2) {
int a = m, b = m, c = m, cnt = 0;
while (true) {
if (a == n && b == n && c == n) {
break;
}
if (cnt % 3 == 0) {
c = min(n, a + b - 1);
} else if (cnt % 3 == 1) {
... | CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.util.Arrays;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x = in.nextInt();
int y = in.nextInt();
int arr[] = new int[3];
arr[0] = y;
arr[1] = y;
arr[2] = y;
int answer=0;
while ((arr[0] < x) || (arr[1] <... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
impo... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.io.*;
import java.util.*;
public class C
{
public static void main(String[] args)
{
MyScanner sc = new MyScanner();
out = new PrintWriter(new BufferedOutputStream(System.out));
int a = sc.nextInt(), b = sc.nextInt();
ArrayList<Integer> inp = new Arr... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int x, y, a[4], counter = 0;
cin >> x >> y;
a[0] = a[1] = a[2] = y;
while (a[0] != a[1] || a[1] != a[2] || a[1] != x) {
sort(a, a + 3);
a[0] = a[1] + a[2];
if (a[0] > x)
a[0] = x;
else
a[0]... | CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, a, b, c, ans;
scanf("%d%d", &y, &x);
a = b = c = x;
ans = 0;
while (a < y || b < y || c < y) {
ans++;
a = b + c - 1;
swap(a, b);
swap(b, c);
}
printf("%d\n", ans);
return 0;
}
| CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | x,y = map(int,input().split())
turn = 0
a = b = c = y
while True:
if a >= x and b >= x and c >= x:
print(turn)
break
if turn % 3 == 0:
a = b + c - 1
if turn % 3 == 1:
b = a + c - 1
if turn % 3 == 2:
c = a + b - 1
turn += 1 | PYTHON3 |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y;
scanf("%d%d", &x, &y);
int a[3], ans = 0;
a[0] = a[1] = a[2] = y;
while (a[0] < x) {
a[0] = a[1] + a[2] - 1;
sort(a, a + 3);
++ans;
}
printf("%d\n", ans);
return 0;
}
| CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
int a[3];
int ans = 0;
int n = 3;
for (int i = 0; i < n; i++) a[i] = y;
while (1) {
sort(a, a + n);
if (a[0] == x) break;
ans++;
a[0] = min(a[1] + a[2] - 1, x);
}
cout << ans << endl;
return 0;
}
| CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class C {
public static void main(String[... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | n ,m = map(int,input().split())
s = [m, m, m]
ans = 0
while s[0] < n:
temp = min(n, s[1] + s[2] - 1)
s[0] = s[1]
s[1] = s[2]
s[2] = temp
ans += 1
print(ans) | PYTHON3 |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | # your code goes here
a=map(int,raw_input().split( ))
#b=[a[0],a[0],a[0]]
c=[a[1],a[1],a[1]]
if 2*a[1]>a[0]:
print 3
else:
cnt=0
while c[0]!=a[0] or c[1]!=a[0] or c[2]!=a[0]:
if c[0]==c[1] and c[1]==c[2]:
c[0]=2*c[0]-1
cnt+=1
else:
mn=min(c)
mx=max(c)
if c[0]==mn and c[0]!=a[0]:
if c[1]==mx:... | PYTHON |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
int abs(int a) {
if (a > 0)
return a;
else
return -a;
}
int main() {
int x, y;
scanf("%d%d", &x, &y);
if (x < y) {
int tmp = x;
x = y;
y = tmp;
}
int triangle[3];
int which[3];
int i = 0;
int count = 0;
triangle[0] = y;
triangle[1] = y;
triangle[2] ... | CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #!/usr/bin/env python
#-*-coding:utf-8 -*-
x,a=map(int,input().split())
b=c=a
s=0
while x>a:
a,b,c=b,c,b-1+c
s+=1
print(s)
| PYTHON3 |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | from sys import stdin
if __name__ == '__main__':
x, y = map(int, stdin.readline().rstrip().split())
a = b = c = y
count = 0
while a < x:
temp = b + c -1
a = b
b = c
c = temp
count += 1
print(count) | PYTHON3 |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
int i, j, x, y;
int ans = 0;
void countSteps(int a, int b, int c) {
if (c == x)
return;
else {
ans++;
c = x < a + b - 1 ? x : a + b - 1;
countSteps(c, a, b);
}
}
using namespace std;
int main() {
cin >> x >> y;
countSteps(y, y, y);
cout << ans << endl;
return 0;
}
| CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.io.PrintWriter;
import java.util.*;
public class C {
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
static void exit() {
sc.close();
out.close();
}
int n, m;
public C () {
n = sc.nextInt();
m = sc.nextInt();
out.println(solve(m, m, m));
... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.util.*;
public class Solution3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int x = sc.nextInt(), y = sc.nextInt();
System.out.println(deEvolution(new int[]{y,y,y},x));
}
public static int deEvolution(int[] arr, int x){
if... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
/*```````````````````````````````````````````````````````````````````````````````````... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, cnt = 0;
cin >> x >> y;
vector<int> tri;
for (int i = 0; i < 3; i++) tri.push_back(y);
while (1) {
int f = 1;
for (int i = 0; i < 3; i++)
if (tri[i] != x) f = 0;
if (f) {
cout << cnt << endl;
return 0;
}
... | CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
int arr[3];
for (int i = 0; i < 3; ++i) {
arr[i] = y;
}
int cnt = 0;
int index = 0;
int max = 0;
bool out = false;
while (arr[index] != x) {
int indexSbl1 = (index - 1);
int indexSbl2 = (index - 2);
i... | CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | //package cf;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
private static int[] s = new int[3];
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
int y = scan.nextInt();
s[0]=s[1]=s[2]=y;
... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import java.util.Scanner;
import java.util.Arrays;
public class Triangles {
public static void main(String[] args) {
int x,y,i,j;
Scanner scan = new Scanner(System.in);
x = scan.nextInt();
y = scan.nextInt();
int res = compute(x,y);
System.out.println(res);
}
... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> triangle;
int x, y, start, temp, a, b, c;
cin >> x >> y;
if (x - y < y) {
cout << "3" << endl;
} else {
temp = 1;
triangle.push_back(y + y - 1);
triangle.push_back(y);
triangle.push_back(y);
sort(triangle.begin(), t... | CPP |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | import javafx.scene.control.ComboBox;
import java.util.Scanner;
/**
* blablabla
*/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x = in.nextInt(), y = in.nextInt();
Triangle triangle = new Triangle(y, y, y);
System.out.println(triangle.count( x));
}
... | JAVA |
712_C. Memory and De-Evolution | Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length x, and he wishes to perform operations to obtain an equilateral triangle of side length y.
In a single second, he can modify the length of a single side of the current triangle such th... | 2 | 9 | x,y=map(int,raw_input().split())
c=0
a=[y]*3
while a[-1]<x:
a=a[1:]+[sum(a[1:])-1]
c+=1
print c+2 | 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.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class CodeForces {
private final BufferedReader reader;
private final PrintWriter writer;
private StringTokenizer tokenizer;
private void solve() {
int n = nextInt();
int[] l = new... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #B.py
n = int(raw_input())
#nums = []
leftM = (0, 0)
rightM = (0, 0)
leftC, rightC = 0, 0
equalC = 0
totalC = 0
for i in range(n):
l, r = [int(k_) for k_ in raw_input().split()]
v = l - r
if v > 0 :
leftC += 1
leftM = max((v, i+1), leftM)
elif v < 0:
rightC += 1
rightM =... | PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
L, R = 0, 0
D = []
for i in range(n):
l, r = map(int, input().split())
L += l
R += r
D.append((l, r))
ans = abs(L - R)
num = 0
for i in range(n):
l, r = D[i]
L1 = L - l + r
R1 = R - r + l
if ans < abs(L1 - R1):
ans = abs(L1 - R1)
num = i + 1
print(num) | 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 abs(x):
if x < 0:
return -x
else:
return x
n = int(raw_input())
l = []
r = []
sl = 0
sr = 0
for i in range(n):
a, b = map(int, raw_input().split())
l += [a]
r += [b]
sl += a
sr += b
maxs = abs(sl - sr)
maxd = -1
for i in range(n):
if abs(sl - l[i] + r[i] - (sr - ... | 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(raw_input())
m=[]
for i in range(x):
a,b=raw_input().split(' ')
m.append([int(a),int(b)])
ld=0
rd=0
left=0
right=0
rr=0
lr=0
for i in range(x):
x=m[i][0]
y=m[i][1]
if x>=y and x-y>=ld:
ld=x-y
lr=i+1
if x<=y and y-x>=rd:
rd=y-x
rr=i+1
left+=x
right+... | 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())
ans = 0
left = 0
right = 0
ml = 0
mr = 0
a = []
for i in range(n):
x,y = map(int,input().split())
a.append((x,y))
left+=x
right+=y
best = abs(left - right)
c = 0
c_ans = 0
for v in a:
c+=1
nl = left
nr = right
nl = nl - v[0] + v[1]
nr = nr - v[1] + v[0]
if abs(n... | 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())
le=0
ri=0
a=[0]*n
b=[0]*n
no=-21
for i in range(n):
l,r=map(int,input().split())
le=le+l
ri=ri+r
a[i]=l
b[i]=r
v=abs(le-ri)
for i in range(n):
l1=le-a[i]+b[i]
r1=ri-b[i]+a[i]
x=abs(l1-r1)
if x>v:
no=i
v=x
if no==-21:
print(0)
else:
print(no+1) | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long leftsum = 0, rightsum = 0;
long n, index = -1;
cin >> n;
int left[n], right[n];
for (long i = 0; i < n; ++i) {
cin >> left[i];
cin >> right[i];
leftsum += left[i];
rightsum += right[i];
}
int max = abs(leftsum - rightsum)... | 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 baobab;
import java.io.*;
import java.util.*;
public class B {
public static void main(String[] args) {
Solver solver = new Solver();
}
static class Solver {
IO io;
public Solver() {
this.io = new IO();
try {
solve();
... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.Map.Entry;
public class Palindrome {
static double eps=(double)1e-6;
static long mod=(int)1e9+7;
static long fn=0;
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int tl = 0, tr = 0;
int l[100100], r[100100];
for (int i = 1; i <= n; i++) {
cin >> l[i] >> r[i];
tl += l[i];
tr += r[i];
}
int ans = abs(tl - tr);
int idx = 0;
for (int i = 1; i <= n; i++) {
tl -= l[i];
tr... | 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
for i in range(n):
L[i],R[i]=map(int,input().split())
ll=sum(L)
rr=sum(R)
a=ll-rr
s=[]
m=abs(a)
p=0
b=False
for i in range(n):
s.append(a+2*R[i]-2*L[i])
if abs(s[i])>abs(m):
m=abs(s[i])
p=i
b=True
if not b:
print(0)
else:
print(p+1)
| PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int a[100001][2];
cin >> n;
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < 2; j++) cin >> a[i][j];
}
int lsum = 0, rsum = 0;
for (i = 0; i < n; i++) {
lsum += a[i][0];
rsum += a[i][1];
}
int templ, tempr, beauty, maxb... | 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=input()
a=[map(int,raw_input().split()) for _ in range(n)]
b=zip(*a)
t=sum(b[0])-sum(b[1])
u,v=-1,t
for i in range(n):
x=t+2*(a[i][1]-a[i][0])
if abs(x)>abs(v):
u,v=i,x
print u+1 | PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.util.*;
import java.io.*;
import java.math.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
public class Tester {
//static long sum=0,sum1=Long.MAX_VALUE;
//DecimalFormat df = new DecimalFormat("#.#####");
public static final long MOD = (long) (1e9 + 7);
// Driver program to test abov... | 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
# sys.stdin=open("input.in",'r')
# sys.stdout=open("out.out",'w')
n=int(input())
z=0
a=[]
x,y=0,0
for i in range(n):
l,r=map(int,input().split())
a.append((l,r))
x+=l
y+=r
m=abs(x-y)
for i in range(n):
k=abs((x-a[i][0]+a[i][1])-(y-a[i][1]+a[i][0]))
if k>m:
z=i+1
m=k
print(z)
| 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.*;
/**
*
* @author Sourav Kumar Paul (spaul100)
* NIT Silchar
*/
public class SolveB {
public static Reader in;
public static PrintWriter out;
public static long mod = 1000000007;
public static long inf = 100000000000000000l;
public static long fac[],inv... | 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 = []
b = []
for _ in range(n):
x,y = map(int,input().split())
a.append(x)
b.append(y)
x = sum(a)
y = sum(b)
ans = abs(x-y)
ind = 0
for i in range(n):
z = abs(((x-a[i])+b[i])-((y-b[i])+a[i]))
if z > ans:
ans = z
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())
a=[]
b=[]
for i in range(n):
x=[int(x) for x in input().split(' ')]
a.append(x[0])
b.append(x[1])
sa=sum(a)
sb=sum(b)
anss=[abs(sa-sb)]
for i in range(n):
nsa=sa-a[i]+b[i]
nsb=sb-b[i]+a[i]
anss.append(abs(nsa-nsb))
print(anss.index(max(anss)))
| 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())
li = []
ri = []
l_sum = 0
r_sum = 0
for i in range(n):
a, b = map(int, input().split())
li.append(a)
ri.append(b)
l_sum += a
r_sum += b
j = -1
diff = abs(l_sum - r_sum)
for i in range(n):
m = abs((l_sum - li[i] + ri[i]) - (r_sum - ri[i] + li[i]))
if m > diff:
j = 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 | n=input()
a=[map(int,raw_input().split()) for i in range(n)]
l=r=0
for ll,rr in a:
l+=ll
r+=rr
ans,k=abs(l-r),0
for i in range(len(a)):
ll,rr=a[i]
ans1=abs(l-r+2*(rr-ll))
if ans<ans1:
ans,k=ans1,i+1
print k
| 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;
vector<pair<int, int> > v;
int cur = 0, max = 0, index = 0, s1 = 0, s2 = 0;
for (int i = 0; i < n; i++) {
int b, c;
cin >> b >> c;
v.push_back(make_pair(b, c));
s1 += b;
s2 += c;
}
max = abs(s1 - s2);
for (in... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(raw_input())
k = -1
sl, sr = 0, 0
l = []
for i in range(n):
left, right = map(int, raw_input().split())
l.append((left, right))
sl, sr = sl + left, sr + right
# print l
# print sl, sr
m = abs(sl - sr)
for i in range(n):
sl, sr = sl - l[i][0] + l[i][1], sr - l[i][1] + l[i][0]
if abs(sl - sr) > m:
k = 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 | #include <bits/stdc++.h>
int n, l[100010], r[100010], tA, tB, Ans, k;
int main() {
scanf("%d", &n);
tA = tB = 0;
for (int i = 1; i <= n; i++)
scanf("%d%d", &l[i], &r[i]), tA += l[i], tB += r[i];
Ans = abs(tA - tB);
for (int i = 1; i <= n; i++)
if (Ans < abs(tA - tB + ((r[i] - l[i]) << 1))) {
k =... | 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() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, flag, i, L = 0, R = 0, a = 0;
cin >> n;
int l[n], r[n], result[n];
for (i = 1; i <= n; i++) {
cin >> l[i] >> r[i];
L += l[i];
R += r[i];
}
int max = abs(L - R);
f... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> arr[100000 + 5];
int main() {
cin >> n;
int L = 0, R = 0;
for (int i = 1; i <= n; i++) {
cin >> arr[i].first >> arr[i].second;
L += arr[i].first;
R += arr[i].second;
}
int ans = abs(L - R);
int id = 0;
for (int 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 | /*
* PDPM IITDM Jabalpur
* Asutosh Rana
*/
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
static long MOD = 1000000007;
public static void main (String[] args) throws java.lang.Exception
{
InputReader in=new InputReader(System.in);
BufferedReader br = new ... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #!/usr/bin/env python3
columns = int(input(''))
values = []
ltotal, rtotal = 0, 0
for i in range(0, columns):
l, r = map(int, input('').split(' '))
values.append((l, r))
ltotal += l
rtotal += r
oldBeauty = abs(ltotal - rtotal)
beauty = []
for i in range(0, columns):
l, r = values[i]
new_ltota... | 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 _ in range(n):
l, r = map(int, input().split())
left.append(l)
right.append(r)
lsum = sum(left)
rsum = sum(right)
beauty = abs(lsum - rsum)
ans = -1
for i in range(n):
new_beauty = abs(lsum - left[i] + right[i] - (rsum - right[i] + left[i]))
if new_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 | //simple input
import java.util.*;
import java.io.*;
public class A{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int[] a1=new int[n+1];
int[] a2=new int[n+1];
int sum1=0;
int sum2=0;
for(int i=1;i<=n;i++){
a1[i]=in.nextInt();
a2[i]=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 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
int N;
cin >> N;
int tot = 0;
int l[100001], r[100001];
for (int i = 1; i <= N; i++) {
cin >> l[i] >> r[i];
tot += l[i] - r[i];
}
int ma = abs(tot);
int ma_n = 0;
for (int i = 1; i <= N; i++) {
int tmp = tot - ... | 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 |
if __name__ == '__main__':
n = int(input())
l = []
r = []
max_lr = 0
max_lr_index = -1
max_rl = 0
max_rl_index = -1
for i in range(n):
lr = list(map(int,input().split()))
l.append(lr[0])
r.append(lr[1])
if (lr[0] - lr[1] > max_lr):
max_lr = lr[0] - lr[1]
max_lr_index = i
if (lr[1] - lr[0] > 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 | Limite = int( raw_input() )
Rpta = 0
Posicion = 0
p = [map(int, raw_input().split()) for _ in xrange( Limite)]
Valores = [pp[0]-pp[1] for pp in p]
AnteRpta = sum( Valores )
ActuRpta = abs( AnteRpta )
for i in xrange( Limite ):
Candidato = abs( AnteRpta - 2*Valores[ i ] )
if ActuRpta < Candidato:
ActuRpt... | 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 Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number_of_columns = sc.nextInt();
int[] left_column = new int[100000]; //Π² Π·Π°Π΄Π°ΡΠ΅ Π±ΡΠ»ΠΎ Π½Π°ΠΏΠΈΡΠ°Π½ΠΎ ΡΡΠΎ ΠΌΠ°ΠΊΡΠΈΠΌΡΠΌ 100
int[] right_column = new int[100000];
... | 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())
P =[ map(int , raw_input().split()) for _ in xrange(N)]
V = [ PP[0]- PP[1] for PP in P ]
S = sum(V)
Mx = abs(S)
Pos = 0
for ___ in xrange(N):
Nx = abs(S-2*V[___])
if Nx>Mx:
Mx,Pos = Nx , ___ +1
print Pos
| PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | T = int(raw_input())
M = -float('inf')
m = float('inf')
S = 0
temp = []
newS = []
for i in xrange(T):
a, b = map(int, raw_input().split() )
S += (a - b)
temp.append(b - a)
newS = [abs(S + 2 * temp[i]) for i in xrange(T)]
newS.append(abs(S))
print (newS.index(max(newS)) + 1) % (T + 1) | PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
beauty_of_column = []
for i in range (0, n):
l, r = [int(x) for x in input().split()]
beauty_of_column.append(l - r)
currentBeauty = sum(beauty_of_column)
res = 0
maxBeauty = abs(currentBeauty)
for i in range (0, n):
beauty = currentBeauty - 2 * beauty_of_column[i]
if abs(beauty) > maxB... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, r = 0, l = 0, num = -1, a[100000], b[100000], max;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
l += a[i];
r += b[i];
}
max = abs(l - r);
for (int i = 0; i < n; i++) {
if (max < abs((l - a[i] + b[i]) - (r - b[i... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(raw_input())
matrix = []
for i in xrange(n):
matrix.append(tuple(map(int, raw_input().split())))
L, R = [],[]
for i in matrix:
L.append(i[0])
R.append(i[1])
a = sum(R)
b = sum(L)
ans = abs(a-b)
index = 0
for i in xrange(n):
if abs(b - 2*L[i] + 2*R[i] - a) > ans:
ans = abs(b - 2*L[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 | import java.lang.Math;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
public class Parade {
public static int sumArr(int[] arr){
int sum = 0;
for(int x : arr)
sum+=x;
return sum;
}
public static void main(String[] args) throws IOException {
InputStream... | JAVA |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int SL[MAXN], SR[MAXN];
int A[MAXN][2], n;
int main() {
while (~scanf("%d", &n)) {
SL[0] = SR[0] = 0;
for (int i = 1; i <= n; i++) {
scanf("%d%d", &A[i][0], &A[i][1]);
SL[i] = A[i][0] + SL[i - 1];
SR[i] = A[i][1] + 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())
Groups = []
Left, Right, CurrentMax, Index = 0, 0, 0, 0,
for i in range(N):
Groups.append(list(map(int, input().split())))
Left, Right = Left + Groups[i][0], Right + Groups[i][1]
CurrentMax = abs(Left - Right)
for i in range(N):
Temp = abs((Left + Groups[i][1] - Groups[i][0]) - (Right + Gro... | 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 Abs(int x) { return x < 0 ? (-x) : x; }
int n, l[100010], r[100010], ans, al, ar, ass;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", &l[i], &r[i]);
al += l[i];
ar += r[i];
}
ass = Abs(al - ar);
for (int 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 | n = 0
a = None
left, rght = -1, -1
def read(t=None):
string = raw_input()
return string if t is None else [t(x) for x in string.split()]
def swap(i):
global left, rght
l = left - a[i][0] + a[i][1]
r = rght - a[i][1] + a[i][0]
b = abs(l-r)
#print "swap: %2d: %3d(%3d, %3d)"%(i+1, b, l, r)
return b
if __name__... | PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | t = int(raw_input())
left = 0
right = 0
soldiers = []
for i in xrange(1, t+1):
l, r = map(int, raw_input().split())
soldiers.append((l, r))
left += l
right += r
index = 0
start = abs(left-right)
for i in xrange(len(soldiers)):
temp = abs((left - soldiers[i][0] + soldiers[i][1]) - (right + soldiers[i][0] - soldi... | PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
l=[];r=[]
la=0
ra=0
for i in range(n):
L,R = map(int,input().split())
l.append(L)
r.append(R)
la+=l[i]
ra+=r[i]
ans = 0
nice = abs(la-ra)
for i in range(n):
if abs((la-l[i]+r[i])-(ra-r[i]+l[i])) > nice:
ans = i + 1
nice = abs((la-l[i]+r[i])-(ra-r[i]+l[i]))
print... | 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.math.*;
public class B {
public static void main(String args[]) {
try {
InputReader in = new InputReader(System.in);
int n = in.readInt();
int l[] = new int[n];
int r[] = new int[n];
int suml = 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.io.*;
import java.util.InputMismatchException;
public class Cf1108B {
private static InputReader in = new InputReader(System.in);
private static OutputWriter out = new OutputWriter(System.out);
private static void solve() throws Exception {
int n = in.readInt();
int[] diff = ... | 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] + [sum(map(int, ('-' + input()).split())) for _ in range(int(input()))]
s, a, b = sum(l), min(l), max(l)
print(l.index(b if s < a + b else a))
# Made By Mostafa_Khaled | 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
l1 = 0
l2 = 0
r1 = 0
r2 = 0
maxd1 = 0
maxd2 = 0
k1 = 0
k2 = 0
for i in range(n):
a, b = map(int,input().split())
l = l + a
r = r + b
if a > b and abs(a - b)>maxd1: #max left
l1 = a
r1 = b
maxd1 = abs(a-b)
k1 = i + 1
#print('max left ... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
a, b = [], []
for i in range(n):
x, y = map(int, input().split())
a.append(x)
b.append(y)
sa = sum(a)
sb = sum(b)
d = abs(sa - sb)
i = 0
for j in range(n):
t = abs((sa + b[j] - a[j]) - (sb + a[j] - b[j]))
if t > d:
d = t
i = j + 1
print(i) | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int lft[1000000 + 5];
int ri8[1000000 + 5];
int main() {
int n;
int rdiff, ldiff, rindx, lindx, sleft, sri8, lx, ly, rx, ry, maxm1, maxm2;
int sLeft, sRi8;
while (cin >> n) {
ldiff = -1, rdiff = -1;
sleft = 0;
sri8 = 0;
sLeft = 0;
sRi8 = 0;
f... | CPP |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int sum1=0;
int sum2=0;
int L[]=new int[n];
int R[]=new int[n];
for(int i=0;i<n;i++) {
int l=sc.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.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int max = -1;
int index = -1;
int L = 0;
int R = 0;
int n = in.nextInt();
int tab[][] = new int[2][n];
for (int i = 0; i < n; i++) {
tab[0][i] = 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 max(int a, int b) {
if (a > b) return a;
return b;
}
int main() {
int n, mx = -1, a = 0, b, l = 0, r = 0, nl, nr;
scanf("%d", &n);
int c[n][2];
for (int i = 0; i < n; i++) {
scanf("%d %d", &c[i][0], &c[i][1]);
l += c[i][0];
r += c[i][1];
}
mx... | 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())
parade = []
for k in range(n):
x = tuple(map(int,input().split()))
parade.append(x)
l = 0
r = 0
for i in parade:
l += i[0]
r += i[1]
beauty = abs(l-r)
def change(i):
return abs(l-r+2*(parade[i][1]-parade[i][0]))
k,m = 0, beauty
for i in range(len(parade)):
if change(i) > m:... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
a = []
sl = 0
sr = 0
for i in range(n):
q,w = map(int,input().split())
a+=[(q,w)]
sl +=q
sr+=w
cur = abs(sr-sl)
m = 0
for i in range(n):
if abs((sl-a[i][0]+a[i][1]) - (sr-a[i][1]+a[i][0])) > cur:
cur = abs((sl-a[i][0]+a[i][1]) - (sr-a[i][1]+a[i][0]))
m = i+1
print(m)... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | n = int(input())
s = [[int(j) for j in input().split()] for k in range(n)]
p = [sum(x) for x in zip(*s)]
q = abs(p[0] - p[1])
index = -1
for i in range(n):
l = p[0] - s[i][0] + s[i][1]
r = p[1] - s[i][1] + s[i][0]
if abs(l - r) > q:
q = abs(l - r)
index = i
print(index + 1) | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 |
import java.util.*;
import java.io.*;
/**
*
* @author Ninja_white
*/
public class Main extends Lectora {
public static void main(String[] args) throws IOException {
int n = cadena2(), s0 = 0, s1 = 0;
int a[][] = new int[n][2];
for (int i = 0; i < n; i++) {
a[i][0] = cadena2... | 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 i in range(n)]
B = []
l = 0
r = 0
for i in range(n):
l += A[i][0]
r += A[i][1]
a = abs(l-r)
B.append(a)
for j in range(n):
if A[j][0]>A[j][1]:
li = A[j][0]-A[j][1]
ln = l-li
rn = r+li
a = abs(ln-rn)
B.append(a)... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int t, l[100009], r[100009], ans;
long long int L = 0, R = 0, mx;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
scanf("%d%d", &l[i], &r[i]);
L += l[i];
R += r[i];
}
mx = abs(L - R);
ans = 0;
for (int i = 0; i < t; i++) {
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 = []
r = []
sum_r = 0
sum_l = 0
max_diff_r = 0
max_r = 0
max_diff_l = 0
max_l = 0
for i in range(0, int(input())):
x, y = input().split(' ')
l.append(int(x))
sum_l+=l[i]
r.append(int(y))
sum_r+=r[i]
if max_diff_r < r[i] - l[i]:
max_r=i+1
max_diff_r=r[i] - l[i]
if max_diff_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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int *Mas = new int[n];
int _l, _r;
for (int i = 0; i < n; i++) {
cin >> _l >> _r;
Mas[i] = _l - _r;
}
int S = 0;
for (int i = 0; i < n; i++) S += Mas[i];
int max = abs(S), index = -1;
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())
mi = 100000000
ma = -100000000
sum = 0
minI = -1
maxI = -1
for i in range(n):
raw = input().split()
l = int(raw[0])
r = int(raw[1])
dif = l - r
if (mi > dif):
mi = dif
minI = i
# minL = l
# minR = r
if (ma < dif):
ma = dif
maxI = 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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Parade
{
public static void main(String[] args)
{
Parade solver = new Parade();... | 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())
l1=[]
r1=[]
L=0
R=0
for i in range(n):
l,r=map(int,input().split())
L+=l
R+=r
l1.append(l)
r1.append(r)
max=abs(L-R)
ans=0
for i in range(n):
if(abs((L-l1[i]+r1[i])-(R-r1[i]+l1[i]))>max):
max=abs((L-l1[i]+r1[i])-(R-r1[i]+l1[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 | n=int(input())
M=[list(map(int,input().split())) for i in range(n) ]
k1=0
k2=0
ma=0
p=0
for i in range(n) :
k1=k1+M[i][0]
k2=k2+M[i][1]
ma=abs(k1-k2)
for i in range(n) :
if abs((k1-M[i][0])-(k2-M[i][1])-M[i][0]+M[i][1])>ma :
ma=abs((k1-M[i][0])-(k2-M[i][1])-M[i][0]+M[i][1])
p=i+1
print(p)
... | 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()
diffs = []
for _ in xrange(n):
l,r = map(int, raw_input().split())
diffs.append(l-r)
curr_diff = sum(diffs)
best = abs(curr_diff)
best_index = -1
for i in xrange(n):
if abs(curr_diff-2*diffs[i]) > best:
best_index = i
best = abs(curr_diff-2*diffs[i])
print best_index + 1
| PYTHON |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | from sys import exit
n = int(input())
R = 0
L = 0
mr = (0, 0)
ml = (0, 0)
for i in range(1, n+1):
(li, ri) = (int(_) for _ in input().split())
R += ri
L += li
if ri > li:
mr = max(mr, (ri - li, i))
elif li > ri:
ml = max(ml, (li - ri, i))
if R + ml[0] > L + mr[0]:
print(ml[1]... | PYTHON3 |
733_B. Parade | Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civilian population also poorly understands from which leg recruits beg... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, b, n1 = 1, n2 = 1;
scanf("%d", &n);
scanf("%d %d", &a, &b);
a -= b;
int mn = a, mx = a, sum = a;
for (int i = 2; i <= n; i++) {
scanf("%d %d", &a, &b);
a -= b;
if (a < mn) {
mn = a;
n1 = i;
}
if (a > mx) {
... | 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[]) throws Exception
{
BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
int runs=Integer.parseInt(f.readLine());
int[][] arr=new int[runs][2];
int left=0;
int right=0;
int max=0;
for(int ... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.