题目链接:http://codeforces.com/contest/831/problem/C

题意:给定k个评委,n个中间结果。 假设参赛者初始分数为x,按顺序累加这k个评委的给分后得到k个结果,在这个过程中,某人只记得其中n次结果(n次结果不一样按照时间顺序来排列),问你参赛者的初始合法分数有多少种。

思路:维护一个评委给分的前缀和,然后枚举每一种可能的初始分数,然后判断当前枚举的这个分数经过k次累加分数后得到的k个结果有n个结果等于给定的中间结果即可。

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<time.h>
#include<stack>
#include<set>
#include<cmath>
#include<functional>
#include<cstdlib>
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
const LL INF = 9223372036854775807L;
const int inf = 0x3f3f3f3f;
const int MAXN = + ;
const int MAXB = 8e6 + ;
set<LL>se;
LL val[MAXN], source[MAXN],pre[MAXN];
LL statu[MAXN];
bool visb[MAXB],vis[MAXB];
int main(){
#ifdef kirito
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int start = clock();
int n, k;
while (~scanf("%d%d",&k,&n)){
se.clear();
memset(visb, , sizeof(visb));
memset(pre, , sizeof(pre));
for (int i = ; i <= k; i++){
scanf("%I64d", &val[i]);
pre[i] += pre[i - ] + val[i];
}
for (int i = ; i <= n; i++){
scanf("%I64d", &source[i]);
visb[source[i] + ] = ;
}
for (int i = ; i <= k; i++){
int cnt = ;
statu[] = source[]-pre[i];
memset(vis, , sizeof(vis));
if (se.count(statu[])){
continue;
}
for (int j = ; j <= k; j++){
statu[j] = statu[j-] + val[j];
if (statu[j] + <MAXB&&visb[statu[j] + ] && vis[statu[j] + ] == false){
cnt++;
vis[statu[j] + ] = true;
}
}
if (cnt == n){
se.insert(statu[]);
}
}
printf("%d\n", se.size());
}
#ifdef LOCAL_TIME
cout << "[Finished in " << clock() - start << " ms]" << endl;
#endif
return ;
}

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - C的更多相关文章

  1. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)

    http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...

  2. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法

    Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...

  3. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C

    A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: ...

  4. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem F (Codeforces 831F) - 数论 - 暴力

    题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum ...

  5. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划

    There are n people and k keys on a straight line. Every person wants to get to the office which is l ...

  6. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 831E) - 线段树 - 树状数组

    Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this int ...

  7. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B

    Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is cons ...

  8. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组

    A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  9. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - D

    题目链接:http://codeforces.com/contest/831/problem/D 题意:在一个一维坐标里,有n个人,k把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...

随机推荐

  1. spring学习笔记之---JDBC Template

    JDBC  Template(简化持久化操作) (一)创建项目 (1)Maven配置 <dependencies> <dependency> <groupId>ju ...

  2. C++ 对象间通信框架 V2.0 ××××××× 之(四)

    类定义:CMemberFuncPointer ======================================================================= // Me ...

  3. Sign on Fence(连续的长为W的一段中最小的数字的最大值)

    题目链接:http://codeforces.com/problemset/problem/484/E 题意:给你个n,n个木板都有高度,宽度都为1 ,给你两个数[l,r]和一个w,求在[l,r]区间 ...

  4. Python Django的安装配置

    学习Django前,我们要确定电脑上是否已经安装了Python,目前Python有两个版本,不过这两个版本并不互相兼容,所以根据个人选择合适的版本. 因为从Django2.0开始将不再支持Python ...

  5. Python编程:从入门到实践—函数

    从函数中修改列表 一家为用户提交的设计制作3D打印模型的公司,需要打印的设计存储在一个列表中,打印后移到另一个列表中. #!/usr/bin/env python # -*- coding:utf-8 ...

  6. 测开之路八十六:python操作sqlite

    创建sqlite数据库,并创建表和数据 python自带sqlite3库可以创建数据库文件 导入库:import sqlite3 创建游标,指定数据库名字:con = sqlite3.connect( ...

  7. GUI_FlowLayout

    void setBounds(x, y, width, height) 设置窗体坐标,窗体大小 import java.awt.Frame; public class IntegerDemo { pu ...

  8. 【MM系列】SAP ABAP BAPI 和 RFC 的区别

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP BAPI 和 ...

  9. 浅谈Java反射机制 之 获取类的字节码文件 Class.forName("全路径名") 、getClass()、class

    另一个篇:获取 类 的 方法 和 属性(包括构造函数) 先贴上Java反射机制的概念: AVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法: 对于任意一个对象,都能够调用它 ...

  10. [SDOI2016]征途 —— 斜率优化DP

    时隔多年没有碰斜率优化了... 想当年被斜率优化虐的死去活来,现在看看...也就那样吧. Pine开始了从S地到T地的征途. 从S地到T地的路可以划分成n段,相邻两段路的分界点设有休息站. Pine计 ...