Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit c66a54e

Browse files
authored
Add files via upload
1 parent 9e10ad8 commit c66a54e

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

Java/angry.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7 2
2+
20
3+
25
4+
18
5+
8
6+
10
7+
3
8+
1

Java/angry.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8

Java/bin/angry.class

2.12 KB
Binary file not shown.

Java/src/angry.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
/*
5+
* Angry Cows: Silver Edition
6+
*/
7+
public class angry {
8+
static List<Integer> field = new ArrayList<Integer>();
9+
//public List<Integer> launchSim(int pos){
10+
//
11+
//}
12+
public static void main(String[] args) throws IOException{
13+
BufferedReader f = new BufferedReader(new FileReader("angry.in"));
14+
StringTokenizer st = new StringTokenizer(f.readLine());
15+
int N = Integer.parseInt(st.nextToken()); // Number of haybales
16+
int K = Integer.parseInt(st.nextToken()); // Number of cows
17+
List<Integer> costs = new ArrayList<Integer>(N - 1);
18+
for(int i = 0; i < N; i ++) {
19+
field.add(Integer.parseInt(f.readLine()));
20+
}
21+
f.close();
22+
field.sort(null);
23+
for(int i = 0; i < (N-1); i ++) {
24+
costs.add(field.get(i+1) - field.get(i));
25+
}
26+
System.out.println(field);
27+
System.out.println(costs);
28+
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("angry.out")));
29+
pw.println(Collections.max(costs));
30+
pw.close();
31+
//System.out.println("");
32+
for(int i = 0 ; i < N; i ++) {
33+
34+
}
35+
}
36+
37+
}

0 commit comments

Comments
 (0)