C. Jury Marks 思维
这个题目虽然是只有1600,但是还是挺思维的。
有点难想。
应该可以比较快的推出的是这个肯定和前缀和有关,
x x+a1 x+a1+a2 x+a1+a2+a3...
x+sum=b
所以我们可以通过b来枚举每一个x,如果这个x可以满足找到m个b,那就说明这个x是合理的。
但是要注意的是,这个sum的去重,为什么要去重呢,因为如果不去虫,就是找到两个相同的 因为x=b-sum
所以可以只要枚举b[1]即可,因为对于每一个b,其中一个确定之后,剩下的b的位置也固定了。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<iomanip>
#define INF 99999999
using namespace std;
const int maxn = 2e6 + ;
typedef long long ll;
int a[maxn];
ll sum[maxn];
map<ll, int>mp; int main()
{
int n, m;
scanf("%d%d", &n, &m);
for(int i=;i<=n;i++)
{
scanf("%lld", &sum[i]);
sum[i] += sum[i - ];
mp[sum[i]] = ;
}
for (int i = ; i <= m; i++) scanf("%d", &a[i]);
sort(sum + , sum + + n);
int len = unique(sum + , sum + + n) - sum - ;
int ans = ;
for(int i=;i<=len;i++)
{
int cnt = , num = a[] - sum[i];
for(int j=;j<=m;j++)
{
if (mp[a[j] - num]) cnt++;
}
if (cnt >= m) ans++;
}
printf("%d\n", ans);
return ;
}
C. Jury Marks 思维的更多相关文章
- C. Jury Marks 思维题
http://codeforces.com/contest/831/problem/C 做的时候想不到,来了个暴力. 对于每个b[i],枚举每一个a[i],就有1个可能的情况. 然后用vector存起 ...
- C. Jury Marks
C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces831C Jury Marks
C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- #424 Div2 Problem C Jury Marks (二分 && 暴力 && std::unique && 思维)
题目链接 :http://codeforces.com/contest/831/problem/C 题意 :选手有一个初始积分,接下来有k个裁判为他加分或减分(时间顺序给出),然后告诉你n(1< ...
- CF831C Jury Marks
思路: 关键在于“插入”一个得分之后,其他所有得分也随之确定了. 实现: #include <iostream> #include <cstdio> #include < ...
- 【Codeforces Round #424 (Div. 2) C】Jury Marks
[Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对 ...
- 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) 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 ...
- CF-831C
C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
随机推荐
- stand up meeting 1/13/2016
part 组员 工作 工作耗时/h 明日计划 工作耗时/h UI 冯晓云 UI测试和调整:与主程序完成合并 6 查漏补缺,扫除UI ...
- stand up meeting 12/8/2015
part 组员 今日工作 工作耗时/h 明日计划 工作耗时/h UI 冯晓云 -------------- -- ----------- -- PDF Reader 朱玉影 ...
- ELK(日志审计系统)
ELk简介及工作流程 ELK即(Elasticsearch + Logstash + Kibana) 下载安装包 系统环境:Contos7.0 Java环境:Portal(这是历史下载地址,我的是 j ...
- 【LeetCode】57. Insert Interval [Interval 系列]
LeetCode中,有很多关于一组interval的问题.大体可分为两类: 1.查看是否有区间重叠: 2.合并重叠区间; 3.插入新的区间: 4. 基于interval的其他问题 [ 做题通用的关键 ...
- 详解 File类
在讲解File类之前,本人先要讲解下 路径,因为我们对于文件的操作是离不开路径的: 目录 路径: File类 文件名称过滤器: 路径: 请观看本人博文 -- <详解 绝对路径与 相对路径> ...
- 2. node xlsx的使用
1. 使用xlsx模块 const xlsx = require('xlsx'); //excel async exportexcel() { let arrayData = [ ['姓名', '电话 ...
- 两种异常(CPU异常、用户模拟异常)的收集
Windows内核分析索引目录:https://www.cnblogs.com/onetrainee/p/11675224.html 两种异常(CPU异常.用户模拟异常)的收集 文章的核心:异常收集 ...
- NER命名实体识别,实体级level的评估,精确率、召回率和F1值
pre = "0 0 B_SONG I_SONG I_SONG 0 B_SONG I_SONG I_SONG 0 0 B_SINGER I_SINGER I_SINGER 0 O O O B ...
- [机器学习实战-Logistic回归]使用Logistic回归预测各种实例
目录 本实验代码已经传到gitee上,请点击查收! 一.实验目的 二.实验内容与设计思想 实验内容 设计思想 三.实验使用环境 四.实验步骤和调试过程 4.1 基于Logistic回归和Sigmoid ...
- windows 删除非法目录
用PHP写错了路径,创建了非法目录,提示不存在该项目 复制下面 添加为批处理文件 DEL /F /A /Q \\?\%1RD /S /Q \\?\%1 将文件移入这个文件