Submission #993008


Source Code Expand

import java.io.*;
import java.util.*;

public class Main {
	FastScanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i + 1 < n; i++) {
			a[i] = in.nextInt();
		}
		int m = in.nextInt();
		if (m != 1) {
			return;
		}
		a[n - 1] = in.nextInt();
		long[] dp = new long[n];
		dp[n - 2] = a[n - 1];
		for (int opPos = n - 2; opPos >= 1; opPos--) {
			dp[opPos] = Math.max(dp[opPos + 1] - a[opPos + 1], a[opPos + 1]
					- dp[opPos + 1]);
		}
		out.println(dp[1] + a[0] - a[1]);
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

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

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

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Submission Info

Submission Time
Task H - Tokaido
User qwerty787788
Language Java8 (OpenJDK 1.8.0)
Score 700
Code Size 2247 Byte
Status WA
Exec Time 1756 ms
Memory 26576 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 700 / 700 0 / 900
Status
AC × 1
WA × 1
AC × 20
AC × 20
WA × 17
Set Name Test Cases
sample sample-01.txt, sample-02.txt
dataset1 sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt
dataset2 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt
Case Name Status Exec Time Memory
01-01.txt AC 214 ms 25524 KB
01-02.txt AC 95 ms 8428 KB
01-03.txt AC 117 ms 9040 KB
01-04.txt AC 170 ms 17516 KB
01-05.txt AC 232 ms 25348 KB
01-06.txt AC 217 ms 25640 KB
01-07.txt AC 168 ms 15304 KB
01-08.txt AC 215 ms 25300 KB
01-09.txt AC 225 ms 26120 KB
01-10.txt AC 96 ms 8420 KB
01-11.txt AC 156 ms 13424 KB
01-12.txt AC 217 ms 24812 KB
01-13.txt AC 214 ms 25320 KB
01-14.txt AC 209 ms 25140 KB
01-15.txt AC 215 ms 25308 KB
01-16.txt AC 207 ms 25184 KB
01-17.txt AC 209 ms 26116 KB
01-18.txt AC 209 ms 25352 KB
01-19.txt AC 212 ms 26576 KB
02-01.txt WA 144 ms 12756 KB
02-02.txt WA 1756 ms 23636 KB
02-03.txt WA 213 ms 23624 KB
02-04.txt WA 223 ms 23412 KB
02-05.txt WA 105 ms 8812 KB
02-06.txt WA 210 ms 25040 KB
02-07.txt WA 206 ms 23640 KB
02-08.txt WA 537 ms 8456 KB
02-09.txt WA 105 ms 8812 KB
02-10.txt WA 173 ms 17228 KB
02-11.txt WA 192 ms 23608 KB
02-12.txt WA 200 ms 23932 KB
02-13.txt WA 220 ms 23652 KB
02-14.txt WA 192 ms 23624 KB
02-15.txt WA 197 ms 24368 KB
02-16.txt WA 201 ms 24788 KB
sample-01.txt AC 98 ms 8528 KB
sample-02.txt WA 98 ms 8424 KB