This repository was archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomework.java
More file actions
80 lines (75 loc) · 2.18 KB
/
homework.java
File metadata and controls
80 lines (75 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Your cow has eaten your homework!
* What do you do?
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class homework{
public static final int LARGE_CONFIG=10001;
public static int getsmall(List<Integer> l) {
int min=LARGE_CONFIG;
for(int i=0;i<l.size();i++) {
if(l.get(i)<min) {
min=l.get(i);
}
}
return min;
}
public static double grade_assignment(List<Integer> homework) {
int sum=0;
//System.out.println("The homework is "+homework);
for(int i=0;i<homework.size();i++) {
sum+=homework.get(i);
}
sum-=getsmall(homework);
return (double) sum/(homework.size()-1);
}
public static List<Integer >make_bessie_eat_homework(ArrayList<Integer> homework,int k) {
//Simulate bessie eating the homework
return homework.subList(k, homework.size());
}
public static void main(String[] args) throws Exception{
//$1();
// TODO Auto-generated method stub
BufferedReader f=new BufferedReader(new FileReader("10.in"));
int N=Integer.parseInt(f.readLine());
ArrayList<Integer> grades=new ArrayList<Integer>();
StringTokenizer st=new StringTokenizer(f.readLine());
for(int i=0;i<N;i++) {
grades.add(Integer.parseInt(st.nextToken()));
}
//System.out.println("homework "+grades);
double bestscore=-1;
double score;
ArrayList<Integer> bestks=new ArrayList<Integer>();
for(int i=1;i<(N-1);i++) {
//for(int i=N-2;i>0;i--) {
//System.out.println("K:"+i);
score=grade_assignment(make_bessie_eat_homework(grades,i));
//System.out.println("Score:"+score);
if(score>bestscore) {
//System.out.println("New Score:"+score);
bestks.clear();
bestks.add(i);
bestscore=score;
}else if(score==bestscore) {
//System.out.println("Same score:"+score);
bestks.add(i);
}
}
f.close();
PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("homework.out")));
for(int a:bestks) {pw.println(a);}
//pw.println(bestks.get(bestks.size()-1));
pw.close();
//$1();
//System.out.println($r());
}
}