zoukankan      html  css  js  c++  java
  • Codeforces Round #424 C

    Jury Marks

    题意:有一个初始分数x,有n个评委按顺序打分a[i](在x的基础上加或者减),过程中有k个分数被记住了b[i],求有多少种可能的分数

    思路:如果是一种可能的分数,那么必然bi在a中都可以被找到,必然b1一定能在a中找到,所以枚举b1=ai,判断是否所有的bi都在ai中出现过,如果是,ans++

    AC代码:

    #include "iostream"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #define ll long long
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a) memset(a,0,sizeof(a))
    #define mp(x,y) make_pair(x,y)
    using namespace std;
    const long long INF = 1e18+1LL;
    const int inf = 1e9+1e8;
    const int N=1e5+100;
    
    int k,n,a[2005],b[2005],ans;
    map<int,int> M;
    set<int> se;
    bool check(int x){
        for(auto j :se){
            M[x+j]=1;
        }
        for(int i=1; i<=n; ++i){
            if(M[b[i]]==0) return 0;
        }
        return 1;
    }
    int main(){
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        cin>>k>>n;
        for(int i=1; i<=k; ++i){
            cin>>a[i];
            if(i>1) a[i]+=a[i-1];
            se.insert(a[i]);
        }
        for(int i=1; i<=n; ++i){
            cin>>b[i];
        }
        for(auto j :se){
            int x=b[1]-j;
            if(check(x)) ans++;
            M.clear();
        }
        cout<<ans;
        return 0;
    }
  • 相关阅读:
    【转】运行维护管理制度
    系统负载超预警 问题定位
    19-多进程学习
    3-Pandas层次化索引&拼接
    2-Anaconda简介&Numpy基础
    1-IPython&jupyter notebook
    18-进程&协程
    17-多线程
    16-网络通信
    15-正则表达式
  • 原文地址:https://www.cnblogs.com/max88888888/p/7191564.html
Copyright © 2011-2022 走看看