Contest Duration: - (local time) (120 minutes) Back to Home

Submission #575512

Source Code Expand

Copy
```import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Printer pr = new Printer(System.out);

int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}

int tamax = Integer.MIN_VALUE;
for (int i = 0; i < n; i++) {
int aomax = Integer.MIN_VALUE;
int tmp = 0;
for (int j = 0; j < n; j++) {
if (i == j) {
continue;
}
int ta = 0;
int ao = 0;
int s = Math.min(i, j);
int e = Math.max(i, j);
for (int k = s; k <= e; k++) {
if ((k - s + 1) % 2 == 1) {
ta += a[k];
} else {
ao += a[k];
}
}

if (ao > aomax) {
aomax = ao;
tmp = ta;
}
}
tamax = Math.max(tamax, tmp);
}

pr.println(tamax);

pr.close();
sc.close();
}

@SuppressWarnings("unused")
private static class Scanner {
Iterator<String> it;

Scanner (InputStream in) {
}

String next() throws RuntimeException  {
try {
if (it == null || !it.hasNext()) {
}
return it.next();
} catch (IOException e) {
throw new IllegalStateException();
}
}

int nextInt() throws RuntimeException {
return Integer.parseInt(next());
}

long nextLong() throws RuntimeException {
return Long.parseLong(next());
}

float nextFloat() throws RuntimeException {
return Float.parseFloat(next());
}

double nextDouble() throws RuntimeException {
return Double.parseDouble(next());
}

void close() {
try {
br.close();
} catch (IOException e) {
//				throw new IllegalStateException();
}
}
}

private static class Printer extends PrintWriter {
Printer(PrintStream out) {
super(out);
}
}
}
```

#### Submission Info

Submission Time 2015-11-21 21:21:08+0900 C - 数列ゲーム garnacha Java8 (OpenJDK 1.8.0) 100 2182 Byte AC 332 ms 27424 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
 AC × 3
 AC × 20
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
All test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt
Case Name Status Exec Time Memory
sample-01.txt AC 307 ms 27424 KB
sample-02.txt AC 298 ms 27328 KB
sample-03.txt AC 295 ms 27240 KB
test-01.txt AC 300 ms 27196 KB
test-02.txt AC 332 ms 27284 KB
test-03.txt AC 306 ms 27212 KB
test-04.txt AC 297 ms 27308 KB
test-05.txt AC 303 ms 27224 KB
test-06.txt AC 303 ms 27320 KB
test-07.txt AC 303 ms 27120 KB
test-08.txt AC 298 ms 27284 KB
test-09.txt AC 304 ms 27316 KB
test-10.txt AC 306 ms 27096 KB
test-11.txt AC 308 ms 27208 KB
test-12.txt AC 305 ms 27260 KB
test-13.txt AC 332 ms 27272 KB
test-14.txt AC 309 ms 27080 KB
test-15.txt AC 324 ms 27296 KB
test-16.txt AC 310 ms 27184 KB
test-17.txt AC 308 ms 27196 KB
test-18.txt AC 308 ms 27292 KB
test-19.txt AC 304 ms 27248 KB
test-20.txt AC 299 ms 27332 KB