Submission #3644195
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
const ll INF = LLONG_MAX/3;
int main(){
int n,m;
scanf(" %d %d", &n, &m);
vector<ll> a(n);
rep(i,n) scanf(" %lld", &a[i]);
vector<ll> aa(2*n);
rep(i,n){
aa[i] = a[i];
aa[n+i] = a[i];
}
vector<ll> pa(2*n+1);
rep(i,2*n) pa[i+1] = pa[i]+aa[i];
// rep(i,2*n+1) printf(" %d: %lld\n", i,pa[i]);
auto calc = [&](int s){
// printf(" CALC %lld\n",pa[s+n/2] - pa[s]);
return pa[s+n/2] - pa[s];
};
ll ans = calc(0);
int x = 0;
rep(i,m){
int k;
scanf(" %d", &k);
x += k-1;
x %= n;
// printf(" x %d\n",x);
ans = max(ans, calc(x));
}
printf("%lld\n", ans);
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:11:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d %d", &n, &m);
^
./Main.cpp:14:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,n) scanf(" %lld", &a[i]);
^
./Main.cpp:37:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %d", &k);
^
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 |
1 ms |
256 KB |
10 |
AC |
1 ms |
256 KB |
11 |
AC |
1 ms |
256 KB |
12 |
AC |
1 ms |
256 KB |
13 |
AC |
17 ms |
3328 KB |
14 |
AC |
12 ms |
1280 KB |
15 |
AC |
26 ms |
4096 KB |
16 |
AC |
26 ms |
4096 KB |
17 |
AC |
26 ms |
4096 KB |
18 |
AC |
26 ms |
4096 KB |
2 |
AC |
1 ms |
256 KB |
3 |
AC |
1 ms |
256 KB |
4 |
AC |
1 ms |
256 KB |
5 |
AC |
1 ms |
256 KB |
6 |
AC |
1 ms |
256 KB |
7 |
AC |
1 ms |
256 KB |
8 |
AC |
1 ms |
256 KB |
9 |
AC |
1 ms |
256 KB |