Submission #101858
Source Code Expand
#include<cstdio> #include<algorithm> typedef long long i64; using namespace std; int N, M; i64 val[100000]; int K[100001]; i64 sums[200001]; int main() { scanf("%d%d", &N, &M); for(int i=0;i<N;i++) scanf("%lld", val+i); for(int i=0;i<M;i++) scanf("%d", K+i); K[M] = 1; sums[0] = 0; for(int i=0;i<2*N;i++){ sums[i+1] = sums[i] + val[i%N]; } int idx = 0; i64 ret = -(1LL << 62LL); for(int i=0;i<=M;i++){ //printf("%d: %lld\n", i, sums[idx+N/2] - sums[idx]); ret = max(ret, sums[idx+N/2] - sums[idx]); idx = (idx + K[i] - 1) % N; } printf("%lld\n", ret); return 0; }
Submission Info
Submission Time | |
---|---|
Task | J - Very Intellectual Card Game |
User | Operasan |
Language | C++ (GCC 4.4.7) |
Score | 100 |
Code Size | 637 Byte |
Status | AC |
Exec Time | 64 ms |
Memory | 3500 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:15: 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
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 | 19 ms | 804 KB |
10 | AC | 21 ms | 808 KB |
11 | AC | 21 ms | 808 KB |
12 | AC | 20 ms | 676 KB |
13 | AC | 48 ms | 2860 KB |
14 | AC | 39 ms | 1580 KB |
15 | AC | 64 ms | 3488 KB |
16 | AC | 64 ms | 3500 KB |
17 | AC | 63 ms | 3500 KB |
18 | AC | 64 ms | 3492 KB |
2 | AC | 21 ms | 928 KB |
3 | AC | 24 ms | 772 KB |
4 | AC | 22 ms | 804 KB |
5 | AC | 21 ms | 680 KB |
6 | AC | 21 ms | 704 KB |
7 | AC | 22 ms | 804 KB |
8 | AC | 22 ms | 760 KB |
9 | AC | 20 ms | 800 KB |