Topic Link: Http://codeforces.com/contest/831/problem/C
Test Instructions: The protagonist watching TV, the TV has K judges to the contestants scored, each judge played Ai points, that is, the initial score of contestants plus these judges score, Equal to a result, but the protagonist does not remember all the results, only remember the n results, namely BJ (plus a number of AI results), now ask you how many of his initial points are possible (note A in chronological order, B is not given in chronological order)
Parse: Direct enumeration Possible initial value, that is b[0]-a[i] , this is a possible initial value, and then you can determine whether it is legal or not
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 2005;
int SUM[MAXN];
int A[MAXN],B[MAXN];
int main (void) {int n,k;
scanf ("%d%d", &n,&k);
for (int i=0;i<n;i++) {scanf ("%d", &a[i]);
SUM[I+1] = Sum[i]+a[i];
} for (int j=0;j<k;j++) scanf ("%d", &b[j]);
Sort (sum+1,sum+n+1);
int m = unique (sum+1,sum+n+1)-sum-1;
int ans = m;
for (int i=1;i<=m;i++) {int s = b[0]-sum[i]; for (int j=0;j<k;j++) {if (!binary_search (sum+1,sum+m+1,b[j]-s)) {ans--
;
Break
}}} printf ("%d\n", ans);
return 0; }