Skip to content

Commit e4e53fc

Browse files
Codechef LongChallenge
1 parent 24ac121 commit e4e53fc

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.io.*;
2+
import java.math.BigInteger;
3+
import java.util.Scanner;
4+
5+
public class DSTAPLS_Distribute_Apples {
6+
public static void main(String[] args) throws IOException {
7+
Scanner br = new Scanner(System.in);
8+
PrintWriter pw = new PrintWriter(System.out);
9+
int t = br.nextInt();
10+
for (int i = 0; i <t ; i++) {
11+
pw.println(disApples(br.nextBigInteger(),br.nextBigInteger()));
12+
}
13+
pw.flush();
14+
br.close();
15+
}
16+
17+
private static String disApples(BigInteger a, BigInteger b) {
18+
if(a.equals(BigInteger.ZERO) || b.equals(BigInteger.ONE)){
19+
return "NO";
20+
}
21+
if(a.compareTo(BigInteger.ZERO)<0){
22+
return "YES";
23+
}
24+
return disApples(a.subtract(b.multiply(b)),b);
25+
}
26+
27+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
import java.io.PrintWriter;
5+
6+
public class MSNSADM1_Football {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
PrintWriter pw = new PrintWriter(System.out);
10+
int t = Integer.parseInt(br.readLine());
11+
for (int i = 0; i <t ; i++) {
12+
int n = Integer.parseInt(br.readLine());
13+
int[] A = new int[n];
14+
int[] B = new int[n];
15+
String[] a = br.readLine().split(" ");
16+
String[] b = br.readLine().split(" ");
17+
for (int j = 0; j <n ; j++) {
18+
A[j] = Integer.parseInt(a[j]);
19+
B[j] = Integer.parseInt(b[j]);
20+
}
21+
pw.println(football(A,B));
22+
}
23+
pw.flush();
24+
br.close();
25+
}
26+
27+
private static int football(int[] a, int[] b) {
28+
int max = 0;
29+
for (int i = 0; i < a.length; i++) {
30+
int score = (a[i]*2)-b[i];
31+
score = score<0?0:score;
32+
max = score>max?score:max;
33+
}
34+
return max*10;
35+
}
36+
}

Competitive Programming.iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<sourceFolder url="file://$MODULE_DIR$/Trees" isTestSource="false" />
2222
<sourceFolder url="file://$MODULE_DIR$/BITWISE ALGORITHMS" isTestSource="false" />
2323
<sourceFolder url="file://$MODULE_DIR$/Basic Code" isTestSource="false" />
24+
<sourceFolder url="file://$MODULE_DIR$/CODECHEF/August-Long-Challenge" isTestSource="false" />
25+
<sourceFolder url="file://$MODULE_DIR$/CODECHEF" isTestSource="false" />
2426
</content>
2527
<orderEntry type="inheritedJdk" />
2628
<orderEntry type="sourceFolder" forTests="false" />

0 commit comments

Comments
 (0)