Submission #101907


Source Code Expand

#include<iostream>
#include<vector>
#include<map>
#include<set>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define mp make_pair
#define all(v) (v).begin(), (v).end()

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const ll INF = 1LL<<50;

int main(void){
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	vector<ll> b(n*3);
	rep(i, n*3-1) b[i+1] = b[i] + a[i % n];
	//rep(i, n) cout << b[i+n/2] - b[i] << endl;

	ll t = 0;
	ll res = b[n/2] - b[0];
	rep(j, m){
		ll k;
		cin >> k;
		--k;
		t += k;
		t %= n;
		if(res < b[t+n/2] - b[t]) res = b[t+n/2] - b[t];
		//cout << b[t+n/2] - b[t] << endl;
	}
	cout << res << endl;
	return 0;
}

Submission Info

Submission Time
Task J - Very Intellectual Card Game
User nikyaudo
Language C++ (G++ 4.6.4)
Score 100
Code Size 718 Byte
Status AC
Exec Time 144 ms
Memory 3884 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 18
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 800 KB
10 AC 20 ms 804 KB
11 AC 21 ms 804 KB
12 AC 22 ms 796 KB
13 AC 100 ms 3236 KB
14 AC 70 ms 1572 KB
15 AC 144 ms 3884 KB
16 AC 140 ms 3876 KB
17 AC 140 ms 3872 KB
18 AC 143 ms 3876 KB
2 AC 22 ms 800 KB
3 AC 21 ms 676 KB
4 AC 20 ms 804 KB
5 AC 21 ms 932 KB
6 AC 21 ms 804 KB
7 AC 21 ms 812 KB
8 AC 22 ms 924 KB
9 AC 21 ms 928 KB