Submission #101940
Source Code Expand
#include <cstdio> int N,M; int as[100002]; long long sum[200002]; int main() { scanf("%d%d",&N,&M); sum[0]=0; for(int i=1;i<=N;i++) { scanf("%d",&as[i]); sum[i]=as[i]; sum[i+N]=as[i]; } for(int i=1;i<=N+N;i++) { sum[i]+=sum[i-1]; } int nw=1; int hf=N/2; long long sol=sum[hf]; for(int i=0;i<M;i++) { int vl; scanf("%d",&vl); nw+=vl-1; if(nw>N) nw-=N; if(sol<sum[nw+hf-1]-sum[nw-1]) sol=sum[nw+hf-1]-sum[nw-1]; } printf("%lld\n",sol); return 0; }
Submission Info
Submission Time | |
---|---|
Task | J - Very Intellectual Card Game |
User | phidnight |
Language | C++ (GCC 4.4.7) |
Score | 100 |
Code Size | 507 Byte |
Status | AC |
Exec Time | 65 ms |
Memory | 2724 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result ./Main.cpp:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result ./Main.cpp:22: 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 | 22 ms | 804 KB |
10 | AC | 21 ms | 924 KB |
11 | AC | 20 ms | 800 KB |
12 | AC | 21 ms | 804 KB |
13 | AC | 48 ms | 2344 KB |
14 | AC | 39 ms | 1312 KB |
15 | AC | 64 ms | 2664 KB |
16 | AC | 64 ms | 2724 KB |
17 | AC | 65 ms | 2712 KB |
18 | AC | 62 ms | 2720 KB |
2 | AC | 21 ms | 928 KB |
3 | AC | 21 ms | 808 KB |
4 | AC | 21 ms | 800 KB |
5 | AC | 21 ms | 928 KB |
6 | AC | 21 ms | 680 KB |
7 | AC | 20 ms | 804 KB |
8 | AC | 20 ms | 676 KB |
9 | AC | 20 ms | 800 KB |