Submission #101841
Source Code Expand
#include <cstdio> #include <algorithm> using namespace std; int a[100000]; long long sum[200001]; int main() { int n, m, x = 0, i; long long ans = -1e18; scanf("%d %d", &n, &m); for (i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i]; for (i = 0; i < n; i++) sum[n + i + 1] = sum[n + i] + a[i]; ans = max(ans, sum[n / 2]); for (i = 0; i < m; i++) { int y; scanf("%d", &y); x += y - 1; x %= n; ans = max(ans, sum[x + n / 2] - sum[x]); } printf("%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | J - Very Intellectual Card Game |
User | not_shiokawa |
Language | C++ (GCC 4.4.7) |
Score | 100 |
Code Size | 696 Byte |
Status | AC |
Exec Time | 65 ms |
Memory | 2732 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result ./Main.cpp:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result ./Main.cpp:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
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 | 21 ms | 676 KB |
10 | AC | 20 ms | 808 KB |
11 | AC | 21 ms | 808 KB |
12 | AC | 21 ms | 680 KB |
13 | AC | 48 ms | 2324 KB |
14 | AC | 40 ms | 1292 KB |
15 | AC | 63 ms | 2656 KB |
16 | AC | 63 ms | 2724 KB |
17 | AC | 63 ms | 2732 KB |
18 | AC | 65 ms | 2724 KB |
2 | AC | 20 ms | 800 KB |
3 | AC | 19 ms | 804 KB |
4 | AC | 22 ms | 680 KB |
5 | AC | 21 ms | 680 KB |
6 | AC | 20 ms | 680 KB |
7 | AC | 21 ms | 804 KB |
8 | AC | 20 ms | 804 KB |
9 | AC | 20 ms | 796 KB |