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把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...
 
随机推荐
- Nginx 作为代理服务与负载均衡
			
代理服务 代理一代为办理(代理理财.代理收货等等) 代理区别 区别在于代理的对象不一样 正向代理代理的对象是客户端 反向代理代理的对象是服务端 反向代理配置 server { listen 80; s ...
 - C# 很久以前几个常用类
			
Base64加密解密 using System; using System.Collections.Generic; using System.Linq; using System.Text; nam ...
 - SpringBoot学习-第一章
			
1.SpringBoot入门 开发环境:JDK1.8 开发工具:IDEA2017.3.1 1.简介: Spring Boot让我们的Spring应用变的更轻量化.比如:你可以仅仅依靠一个Java类来运 ...
 - [CSP-S模拟测试]:ants(回滚莫队)
			
题目描述 然而贪玩的$dirty$又开始了他的第三个游戏. $dirty$抓来了$n$只蚂蚁,并且赋予每只蚂蚁不同的编号,编号从$1$到$n$.最开始,它们按某个顺序排成一列.现在$dirty$想要进 ...
 - 笨办法学Python(learn python the hard way)--练习程序42
			
下面是练习42,基于python3 #ex42.py 1 class TheThing(object): 2 #__init__为class设置内部变量的方式,正常情况下函数内的变量与外部没有关联,但 ...
 - curl_init raw传递json参数
			
protected function curl_vm_record($url, $platform, $authorization, $jsonStr) { $ch = curl_init(); cu ...
 - (转)C#_WinForm接收命令行参数
			
本文转载自:http://blog.csdn.net/lysc_forever/article/details/38356007 首先,我要仔细的声明下,本文讲的是接受命令行参数,让程序启动.而不是启 ...
 - list、tuple、dict加*星号
			
*相当于解压的作用,当list中只有一个元素时,利用*作用相当于直接去[],去[]后的数据类型是字符串. _list = [1,2,3] _tuple = (1,2,3) _dict = {1:'a' ...
 - R语言中的几种数据结构
			
R语言中的几种数据结构 一 R中对象的5种基本类型 字符(character) 整数 (integer) 复数(complex) 逻辑(logical:True/False) 数值(numeric: ...
 - 应用安全-Web安全-注入篇
			
asp站点 ()and = 和 and =)服务器类型判断(ACCESS MSSQL) http://URL.asp?id=24 and (select count(*) from sysobject ...