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 ...
随机推荐
- 原生js俄罗斯方块
效果图 方块定位原理通过16宫格定位坐标,把坐标存到数组中去 [ [[2,0],[2,1],[2,2],[1,2]],//L [[1,1],[2,1],[2,2],[2,3]], //左L [[2,0 ...
- Cyclic Nacklace 杭电3746
CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, ...
- 杭电 How far away ?
There are n houses in the village and some bidirectional roads connecting them. Every day peole alwa ...
- 详解 继承(下)—— super关键字 与 多态
接上篇博文--<详解 继承(上)-- 工具的抽象与分层> 废话不多说,进入正题: 本人在上篇"故弄玄虚",用super();解决了问题,这是为什么呢? 答曰:子类中所有 ...
- 《Spring In Action》阅读笔记之装配bean
Spring主要装配机制 1.在XML中进行显式配置 2.在Java中进行显式配置 3.隐式的的bean发现机制和自动装配 自动化装配bean Spring从两个角度来实现自动化装配 1.组件扫描:S ...
- 重磅!阿里发布《Java开发手册(泰山版)》
最近,阿里的<Java开发手册>又更新了,这个版本历经一年的修炼,取名:<Java开发手册(泰山版)>正式出道. 正所谓无规矩不成方圆,在程序员的世界里,也存在很多规范,阿里出 ...
- MySQL 50题练习
表名和字段 –1.学生表 Student(s_id,s_name,s_birth,s_sex) –学生编号,学生姓名, 出生年月,学生性别 –2.课程表 Course(c_id,c_name,t_id ...
- Springboot:JSR303数据校验(五)
@Validated //开启JSR303数据校验注解 校验规则如下: [一]空检查 @Null 验证对象是否为null @NotNull 验证对象是否不为null, 无法查检长度为0的字符串 @No ...
- QMessage自动定时关闭
QMessageBox *box = new QMessageBox(QMessageBox::Information,tr("test"),tr("testtest&q ...
- What does __GNUC__ mean?
It indicates that I'm a GNU compiler and you can use GNU extensions. https://stackoverflow.com/quest ...