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把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...
随机推荐
- sh_01_hello
sh_01_hello print("hello python") print("你好世界")
- C++ 对象间通信框架 V2.0 ××××××× 之(三)
类定义:CSignalSlot ======================================================================= // SignalSlo ...
- AI移动,缓慢转身设置(针对AI Character)
AICharacter自身: Use Controller Rotation Yaw设为False Auto Possess AI 设为 Placed in World or Spawned Char ...
- Spring Cloud架构教程 (六)消息驱动的微服务【Dalston版】
Spring Cloud Stream是一个用来为微服务应用构建消息驱动能力的框架.它可以基于Spring Boot来创建独立的.可用于生产的Spring应用程序.它通过使用Spring Integr ...
- 小程序app.js小结
小程序app.js app.js import { ApiUrl } from 'utils/apiurl.js'; import { httpReq } from 'utils/http.js'; ...
- clojure 语法
Clojure 是一种运行在 Java 平台上的 LISP 方言,LISP 是一种以表达性和功能强大著称的编程语言. ; 分号作为注释的开始 ; clojure 用括号把元素括起来,元素之间用空格隔开 ...
- Linux安装nslookup命令
做DNS的人都知道nslookup命令是做什么用的,windows系统自带的.但是linux系统是不自带这个命令的,需要人手动安装.如果您不记得这是哪个软件包提供这个命令的话,那您还真会有些麻烦了.下 ...
- EF2:Entity Mysql Sample
1)概念 Entity Framework: 全称ADO.NET Entity Framework,是微软开发的基于ADO.NET的ORM(Object/Relational Mapping)框架.百 ...
- C# datatable 导出到Excel
datatable导出到Excel /// <summary> /// 将DataTable导出为Excel文件(.xls) /// </summary> /// <pa ...
- Generative Model vs Discriminative Model
In this post, we are going to compare the two types of machine learning models-generative model and ...