-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTitanRuins.java
More file actions
29 lines (28 loc) · 812 Bytes
/
TitanRuins.java
File metadata and controls
29 lines (28 loc) · 812 Bytes
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
/*
* Timus OJ - 1910
* Titan Ruins: Hidden Entrance
*/
import java.io.*;
import java.util.*;
public class TitanRuins {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(f.readLine());
int[] forces = new int[n];
StringTokenizer st = new StringTokenizer(f.readLine());
for (int i = 0; i < n; i++) {
forces[i] = Integer.parseInt(st.nextToken());
}
int max = Integer.MIN_VALUE;
int res = 2;
for (int i = 0; i < n - 2; i++) {
if (forces[i] + forces[i + 1] + forces[i + 2] > max) {
max = forces[i] + forces[i + 1] + forces[i + 2];
res = i + 2;
}
}
System.out.println(max + " " + res);
f.close();
System.exit(0);
}
}