Code Submission Evaluation System Login

Datatähti 2015 loppu

Start:2015-01-29 12:15:00
End:2015-01-29 17:15:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2015 loppu - Results
History
2015-01-29 14:10:2412
2015-01-29 14:03:33?
Task:Pörssihai
Sender:fergusq
Submission time:2015-01-29 14:03:33
Language:Java
Status:BUSTED

Code

public class Pörssi {

	static double keskiarvo(int a, int l, int[] arr) {
		int koko = l-a+1;
		double summa = 0;
		for (int i = a; i <= l; i++) {
			summa += arr[i];
		}
		return summa/(double)koko;
	}
	
	public static void main(String[] args) {
		IO io = new IO();
		
		int n = io.nextInt();
		int[] a = new int[n], v = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = io.nextInt();
			double mka = 0;
			int mkai = 0;
			for (int j = 0; j <= i; j++) {
				double ka = keskiarvo(i-j, i, a);
				//System.out.println(i + ":" + j + " " + ka);
				if (mka <= ka) {
					mka = ka;
					mkai = j+1;
				}
			}
			v[i] = mkai;
		}
		
		for (int i = 0; i < n; i++) io.print(v[i] + " ");
		
		io.close();
	}
	
}