Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - C
题目链接: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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C
A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - D
题目链接:http://codeforces.com/contest/831/problem/D 题意:在一个一维坐标里,有n个人,k把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...
随机推荐
- MapServer教程3
Compiling on Unix Compiling on Win32 PHP MapScript Installation .NET MapScript Compilation IIS Setup ...
- CharacterEncodingFilter详解
字符编码过滤器 (Spring框架对字符编码的处理) 基于函数回调,对所有请求起作用,只在容器初始化时调用一次,依赖于servlet容器. web.xml配置文件 <filter> &l ...
- JavaVM & JNIEnv
JNIEnv提供了大多数的JNI函数.你的本地方法都会接收JNIEnv作为第一个参数.JNIEnv用于本地线程存储.因此,你不能在线程间共享同一个JNIEnv.如果一个代码段没有其他方式获取它自身线程 ...
- 查看Linux中lanmp的各软件编译参数
转载 如何查看已经安装的nginx.apache.mysql和php的编译参数 Mysql查看mysql编译参数 Mysql5.4及之前版本查看编译安装参数,进入到mysql安装目录的bin下面 $ ...
- jenkins执行 pod install 报错 CocoaPods requires your terminal to be using UTF-8 encoding. Consider adding the following to ~/.profile:
错误提示是: CocoaPods 需要终端使用utf-8编码 解决办法
- sql时间类型相关
1.现在时间 NOW() 示例: select * from users where date<now() 2.时间相减 INTERVAL ' DAY 示例: ' DAY 3.timestamp ...
- Free Pascal User’s Guide
https://www.freepascal.org/docs-html/current/user/user.html
- Spring MVC 向页面传值-Map、Model和ModelMap https://www.cnblogs.com/caoyc/p/5635878.html
Spring MVC 向页面传值-Map.Model和ModelMap 除了使用ModelAndView方式外.还可以使用Map.Model和ModelMap来向前台页面创造 使用后面3种方式,都是在 ...
- 16/7/7_PHP-访问控制
访问控制 前面的小节,我们已经接触过访问控制了,访问控制通过关键字public,protected和private来实现.被定义为公有的类成员可以在任何地方被访问.被定义为受保护的类成员则可以被其自身 ...
- 【FICO系列】SAP FICO 基本概念
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[FICO系列]SAP FICO 基本概念 ...