Submission #101927
Source Code Expand
import static java.lang.System.in; import static java.lang.System.out; import java.io.*; import java.util.*; public class Main { static final double EPS = 1e-10; static final double INF = 1 << 31; static final double PI = Math.PI; public static Scanner sc = new Scanner(in); StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public void run() throws IOException { String input; String[] inputArray; input = br.readLine(); inputArray = input.split(" "); int n = Integer.valueOf(inputArray[0]); int m = Integer.valueOf(inputArray[1]); long [] a = new long[n+1]; long [] sum = new long[n+1]; input = br.readLine(); inputArray = input.split(" "); for (int i=1; i<=n; i++){ a[i] = Long.valueOf(inputArray[i-1]); sum[i] = sum[i-1] + a[i]; } input = br.readLine(); inputArray = input.split(" "); int l =0; long ans = sum[n/2]; for (int i=0; i<m; i++){ int x = Integer.valueOf(inputArray[i]); l = (l+x-1)%n; if (l+n/2>n) ans = Math.max(ans, sum[n] - sum[l] + sum[(l+n/2)%n]); else ans = Math.max(ans,sum[l+n/2]-sum[l]); } sb.append(ans); ln(sb); } public static void main(String[] args) throws IOException { new Main().run(); } public static void ln(Object obj) { out.println(obj); } }
Submission Info
Submission Time | |
---|---|
Task | J - Very Intellectual Card Game |
User | AND10 |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1378 Byte |
Status | AC |
Exec Time | 702 ms |
Memory | 51744 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 2, 3, 4, 5, 6, 7, 8, 9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1 | AC | 435 ms | 22960 KB |
10 | AC | 409 ms | 22832 KB |
11 | AC | 428 ms | 22828 KB |
12 | AC | 418 ms | 22832 KB |
13 | AC | 662 ms | 46268 KB |
14 | AC | 640 ms | 40132 KB |
15 | AC | 693 ms | 51744 KB |
16 | AC | 702 ms | 51452 KB |
17 | AC | 692 ms | 51572 KB |
18 | AC | 697 ms | 51292 KB |
2 | AC | 423 ms | 22960 KB |
3 | AC | 445 ms | 22836 KB |
4 | AC | 435 ms | 22824 KB |
5 | AC | 435 ms | 22956 KB |
6 | AC | 426 ms | 22816 KB |
7 | AC | 417 ms | 22832 KB |
8 | AC | 429 ms | 22824 KB |
9 | AC | 418 ms | 22956 KB |