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 ...
随机推荐
- public、private、protected继承区别
- group_concat有长度限制
group_concat有长度限制 group_concat 详细用法请点此链接. group_concat有长度限制!长度陷阱用了group_concat后,select里如果使用了li ...
- not found 什么时候触发
eq: BEGIN DECLARE EXIT HANDLER FOR NOT FOUND SET o_state = 999; select count(1) into ...
- ftl中几个特殊的用法
@ 注意${}为变量的渲染显示,即先计算后打印出来,而<>里面为定义等操作符的定义 ,而首尾2个<>中间部分一般为计算打印部分 @数据模型中如果不是以map数据来封装的,而是直 ...
- Docker-Bridge Network 02 容器与外部通信
本小节介绍bridge network模式下,容器与外部的通信. 1.前言2.容器访问外部2.1 访问外网2.2 原理2.3 一张图总结2.4 抓包3.外部访问容器3.1 创建nginx容器并从外部访 ...
- linux常用命令整理(一)
1.sort(排序) 典型例题:sort -t: -k3n /etc/passwd 以冒号为分隔符根据第三个域的数字大小进行排序(默认分隔符是空格) 2.uniq(去除文件中的连续重复行) 典型例题: ...
- 时间格式的转化 vue与js 年月日 时分秒
首先使用原生转化的方法 第一种 //时间转换 dateStr(d, sign) { //如果没有传递符号,给一个默认的符号 if (!sign) { sign = '-' } //获取d里面年月日时分 ...
- [apue] getopt 可能重排参数
看第21章时,介绍到了解析命令行的神器 getopt,了解了 linux 下处理通用命令行的方法. 命令行可分为参数与选项,其中不带 - 或 -- 前缀的为参数,对一个命令而言数量是固定的,多个参数之 ...
- 如何将你的 Vue.js 项目部署在云开发静态托管之上
云开发静态托管是云开发提供的静态网站托管的能力,静态资源(HTML.CSS.JavaScript.字体等)的分发由腾讯云对象存储 COS 和拥有多个边缘网点的腾讯云 CDN 提供支持. 在云开发静态托 ...
- 详解 HashMap
本篇博文的知识点,在我们的日常生活中,应用十分广阔.比如:每个学生,都有自己的对应的学号.每一个公民,都有自己的身份证号- - 相信看到这里,有的同学基本上已经猜到了这个类的主要用途.那么,话不多说, ...