Codeforces 831C Jury Marks

Source: Internet
Author: User

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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.